-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(headless): dispatch action when fetchMoreResults() is called from…
… a folded result list controller (#3363) https://coveord.atlassian.net/browse/KIT-2865
- Loading branch information
1 parent
29cd00a
commit d33048f
Showing
6 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/headless/src/controllers/folded-result-list/headless-folded-result-list.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {SearchAppState} from '../..'; | ||
import {loadCollection} from '../../features/folding/folding-actions'; | ||
import {fetchMoreResults} from '../../features/search/search-actions'; | ||
import { | ||
MockSearchEngine, | ||
buildMockResult, | ||
buildMockSearchAppEngine, | ||
createMockState, | ||
} from '../../test'; | ||
import { | ||
FoldedResultList, | ||
buildFoldedResultList, | ||
} from './headless-folded-result-list'; | ||
|
||
describe('folded result list', () => { | ||
let state: SearchAppState; | ||
let engine: MockSearchEngine; | ||
let foldedResultList: FoldedResultList; | ||
|
||
function initFoldedResultList() { | ||
engine = buildMockSearchAppEngine({state}); | ||
foldedResultList = buildFoldedResultList(engine); | ||
} | ||
|
||
beforeEach(() => { | ||
state = createMockState(); | ||
state.search.response.totalCountFiltered = 100; | ||
initFoldedResultList(); | ||
}); | ||
|
||
it('#loadCollection dispatches the folding #loadCollection action', () => { | ||
foldedResultList.loadCollection({ | ||
children: [], | ||
isLoadingMoreResults: false, | ||
moreResultsAvailable: false, | ||
result: buildMockResult(), | ||
}); | ||
|
||
expect(engine.findAsyncAction(loadCollection.pending)).toBeTruthy(); | ||
}); | ||
it('#fetchMoreResults dispatches the search #fetchMoreResults action', () => { | ||
foldedResultList.fetchMoreResults(); | ||
|
||
expect(engine.findAsyncAction(fetchMoreResults.pending)).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ss/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {loadCollection} from '../../../features/folding/insight-folding-actions'; | ||
import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions'; | ||
import {InsightAppState} from '../../../state/insight-app-state'; | ||
import {buildMockResult} from '../../../test'; | ||
import { | ||
MockInsightEngine, | ||
buildMockInsightEngine, | ||
} from '../../../test/mock-engine'; | ||
import {buildMockInsightState} from '../../../test/mock-insight-state'; | ||
import { | ||
FoldedResultList, | ||
buildFoldedResultList, | ||
} from './headless-insight-folded-result-list'; | ||
|
||
describe('insight folded result list', () => { | ||
let state: InsightAppState; | ||
let engine: MockInsightEngine; | ||
let foldedResultList: FoldedResultList; | ||
|
||
function initFoldedResultList() { | ||
engine = buildMockInsightEngine({state}); | ||
foldedResultList = buildFoldedResultList(engine); | ||
} | ||
|
||
beforeEach(() => { | ||
state = buildMockInsightState(); | ||
state.search.response.totalCountFiltered = 100; | ||
initFoldedResultList(); | ||
}); | ||
|
||
it('#loadCollection dispatches the insight folding #loadCollection action', () => { | ||
foldedResultList.loadCollection({ | ||
children: [], | ||
isLoadingMoreResults: false, | ||
moreResultsAvailable: false, | ||
result: buildMockResult(), | ||
}); | ||
|
||
expect(engine.findAsyncAction(loadCollection.pending)).toBeTruthy(); | ||
}); | ||
|
||
it('#fetchMoreResults dispatches the insight search #fetchMoreResults action', () => { | ||
foldedResultList.fetchMoreResults(); | ||
|
||
expect(engine.findAsyncAction(fetchMoreResults.pending)).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters