Skip to content

Commit 56a73ee

Browse files
test: transform snapshot into rtl test 2/2 (#1757)
* test: remove snapshots and use rtl tests * test: add expected result on map search
1 parent bf95916 commit 56a73ee

File tree

7 files changed

+34
-1281
lines changed

7 files changed

+34
-1281
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"i18n_extract": "fedx-scripts formatjs extract",
1616
"lint": "fedx-scripts eslint --ext .js --ext .jsx --ext .ts --ext .tsx .",
1717
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx --ext .ts --ext .tsx .",
18-
"snapshot": "fedx-scripts jest --updateSnapshot",
1918
"start": "fedx-scripts webpack-dev-server --progress",
2019
"start:with-theme": "paragon install-theme && npm start && npm install",
2120
"dev": "PUBLIC_PATH=/learning/ MFE_CONFIG_API_URL='http://localhost:8000/api/mfe_config/v1' fedx-scripts webpack-dev-server --progress --host apps.local.openedx.io",

src/course-home/courseware-search/__snapshots__/map-search-response.test.js.snap

Lines changed: 0 additions & 306 deletions
This file was deleted.

src/course-home/courseware-search/map-search-response.test.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('mapSearchResponse', () => {
1010
response = mapSearchResponse(camelCaseObject(mockedResponse));
1111
});
1212

13-
it('should match snapshot', () => {
14-
expect(response).toMatchSnapshot();
13+
it('should match number of results', () => {
14+
expect(response.results.length).toBe(mockedResponse.results.length);
1515
});
1616

1717
it('should match expected filters', () => {
@@ -24,6 +24,25 @@ describe('mapSearchResponse', () => {
2424
];
2525
expect(response.filters).toEqual(expectedFilters);
2626
});
27+
28+
it('should match expected results', () => {
29+
const mockFirstResult = mockedResponse.results[0];
30+
const expectedFirstResult = {
31+
id: mockFirstResult.data.id,
32+
title: mockFirstResult.data.content.display_name,
33+
type: mockFirstResult.data.content_type.toLowerCase(),
34+
location: mockFirstResult.data.location,
35+
url: mockFirstResult.data.url,
36+
contentHits: 0,
37+
score: mockFirstResult.score,
38+
};
39+
expect(response.results[0]).toEqual(expectedFirstResult);
40+
});
41+
42+
it('should match expected ms and max score', () => {
43+
expect(response.maxScore).toBe(mockedResponse.max_score);
44+
expect(response.ms).toBe(mockedResponse.took);
45+
});
2746
});
2847

2948
describe('when the a keyword is provided', () => {

0 commit comments

Comments
 (0)