|
9 | 9 | } from '../../testUtils';
|
10 | 10 | import mockResult from '../__mocks__/collection-search.json';
|
11 | 11 | import mockEmptyResult from '../../search-modal/__mocks__/empty-search-result.json';
|
12 |
| -import { mockCollection, mockContentLibrary, mockLibraryBlockTypes, mockXBlockFields } from '../data/api.mocks'; |
| 12 | +import { |
| 13 | + mockCollection, mockContentLibrary, mockLibraryBlockTypes, mockXBlockFields, |
| 14 | +} from '../data/api.mocks'; |
13 | 15 | import { mockContentSearchConfig } from '../../search-manager/data/api.mock';
|
14 | 16 | import { mockBroadcastChannel } from '../../generic/data/api.mock';
|
15 | 17 | import { LibraryLayout } from '..';
|
@@ -38,27 +40,6 @@ const returnEmptyResult = (_url, req) => {
|
38 | 40 | return mockEmptyResult;
|
39 | 41 | };
|
40 | 42 |
|
41 |
| -/** |
42 |
| - * Returns 2 components from the search query. |
43 |
| - * This lets us test that the StudioHome "View All" button is hidden when a |
44 |
| - * low number of search results are shown (<=4 by default). |
45 |
| -*/ |
46 |
| -const returnLowNumberResults = (_url, req) => { |
47 |
| - const requestData = JSON.parse(req.body?.toString() ?? ''); |
48 |
| - const query = requestData?.queries[0]?.q ?? ''; |
49 |
| - const newMockResult = { ...mockResult }; |
50 |
| - // We have to replace the query (search keywords) in the mock results with the actual query, |
51 |
| - // because otherwise we may have an inconsistent state that causes more queries and unexpected results. |
52 |
| - newMockResult.results[0].query = query; |
53 |
| - // Limit number of results to just 2 |
54 |
| - newMockResult.results[0].hits = mockResult.results[0]?.hits.slice(0, 2); |
55 |
| - newMockResult.results[0].estimatedTotalHits = 2; |
56 |
| - // And fake the required '_formatted' fields; it contains the highlighting <mark>...</mark> around matched words |
57 |
| - // eslint-disable-next-line no-underscore-dangle, no-param-reassign |
58 |
| - newMockResult.results[0]?.hits.forEach((hit) => { hit._formatted = { ...hit }; }); |
59 |
| - return newMockResult; |
60 |
| -}; |
61 |
| - |
62 | 43 | const path = '/library/:libraryId/*';
|
63 | 44 | const libraryTitle = mockContentLibrary.libraryData.title;
|
64 | 45 | const collectionTitle = mockCollection.collectionData.title;
|
@@ -94,7 +75,7 @@ describe('<LibraryCollectionPage />', () => {
|
94 | 75 | path,
|
95 | 76 | routerProps: {
|
96 | 77 | initialEntries: [`/library/${libId}/collections/${colId}`],
|
97 |
| - } |
| 78 | + }, |
98 | 79 | });
|
99 | 80 | };
|
100 | 81 |
|
|
0 commit comments