Skip to content

Commit 5cae8ae

Browse files
test: remove snapshots
1 parent 31c5445 commit 5cae8ae

File tree

5 files changed

+28
-116
lines changed

5 files changed

+28
-116
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"dev": "PUBLIC_PATH=/learner-dashboard/ MFE_CONFIG_API_URL='http://localhost:8000/api/mfe_config/v1' fedx-scripts webpack-dev-server --progress --host apps.local.openedx.io",
2020
"test": "TZ=GMT fedx-scripts jest --coverage --passWithNoTests",
2121
"quality": "npm run lint-fix && npm run test",
22-
"watch-tests": "jest --watch",
23-
"snapshot": "fedx-scripts jest --updateSnapshot"
22+
"watch-tests": "jest --watch"
2423
},
2524
"author": "edX",
2625
"license": "AGPL-3.0",

src/__snapshots__/index.test.jsx.snap

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

src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap

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

src/containers/CourseCard/components/CourseCardDetails/index.test.jsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React from 'react';
2-
import { render } from '@testing-library/react';
1+
import { render, screen } from '@testing-library/react';
32

43
import CourseCardDetails from '.';
54

@@ -48,23 +47,36 @@ describe('CourseCard Details component', () => {
4847
return separatorsCount;
4948
};
5049

51-
test('has change session button on entitlement course', () => {
50+
it('has change session button on entitlement course', () => {
5251
const wrapper = createWrapper();
53-
expect(wrapper.container).toMatchSnapshot();
52+
const sessionButton = screen.getByRole('button', { name: defaultHooks.changeOrLeaveSessionMessage });
53+
expect(sessionButton).toBeInTheDocument();
54+
55+
const accessMessage = screen.getByText((text) => text.includes(defaultHooks.accessMessage));
56+
expect(accessMessage).toBeInTheDocument();
5457
// it has 3 separator, 4 column
5558
expect(fetchSeparators(wrapper)).toBe(3);
5659
});
5760

58-
test('has change session button on entitlement course but no access message', () => {
61+
it('has change session button on entitlement course but no access message', () => {
5962
const wrapper = createWrapper({ accessMessage: null });
60-
expect(wrapper.container).toMatchSnapshot();
63+
const sessionButton = screen.getByRole('button', { name: defaultHooks.changeOrLeaveSessionMessage });
64+
expect(sessionButton).toBeInTheDocument();
65+
66+
const accessMessage = screen.queryByText((text) => text.includes(defaultHooks.accessMessage));
67+
expect(accessMessage).toBeNull();
68+
6169
// it has 2 separator, 3 column
6270
expect(fetchSeparators(wrapper)).toBe(2);
6371
});
6472

65-
test('does not have change session button on regular course', () => {
73+
it('does not have change session button on regular course', () => {
6674
const wrapper = createWrapper({ isEntitlement: false });
67-
expect(wrapper.container).toMatchSnapshot();
75+
const sessionButton = screen.queryByRole('button', { name: defaultHooks.changeOrLeaveSessionMessage });
76+
expect(sessionButton).toBeNull();
77+
78+
const accessMessage = screen.getByText((text) => text.includes(defaultHooks.accessMessage));
79+
expect(accessMessage).toBeInTheDocument();
6880
// it has 2 separator, 3 column
6981
expect(fetchSeparators(wrapper)).toBe(2);
7082
});

src/index.test.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ jest.mock('@edx/frontend-platform', () => ({
3434
}));
3535

3636
jest.mock('data/store', () => ({ redux: 'store' }));
37-
jest.mock('./App', () => 'App');
38-
jest.mock('components/NoticesWrapper', () => 'NoticesWrapper');
37+
jest.mock('./App', () => jest.fn(() => <div>App</div>));
38+
jest.mock('components/NoticesWrapper', () => jest.fn(() => <div>NoticesWrapper</div>));
39+
40+
jest.unmock('@edx/frontend-platform/i18n');
41+
jest.unmock('@openedx/paragon');
42+
jest.unmock('react');
3943

4044
describe('app registry', () => {
4145
let getElement;
@@ -55,16 +59,12 @@ describe('app registry', () => {
5559
const callArgs = subscribe.mock.calls[0];
5660
expect(callArgs[0]).toEqual(APP_READY);
5761
callArgs[1]();
58-
const [rendered] = mockRender.mock.calls[0];
59-
expect(rendered).toMatchSnapshot();
6062
});
61-
test('subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element', () => {
63+
test('subscribe: APP_INIT_ERROR.', () => {
6264
const callArgs = subscribe.mock.calls[1];
6365
expect(callArgs[0]).toEqual(APP_INIT_ERROR);
6466
const error = { message: 'test-error-message' };
6567
callArgs[1](error);
66-
const [rendered] = mockRender.mock.calls[0];
67-
expect(rendered).toMatchSnapshot();
6868
});
6969
test('initialize is called with requireAuthenticatedUser', () => {
7070
expect(initialize).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)