Skip to content

Commit 72e7b20

Browse files
diana-villalvazo-wguarbrandes
authored andcommitted
test: Remove react-unit-test-utils
1 parent 815401b commit 72e7b20

File tree

115 files changed

+2581
-9938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2581
-9938
lines changed

package-lock.json

Lines changed: 755 additions & 5342 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"i18n_extract": "openedx formatjs extract",
2323
"lint": "openedx lint .",
2424
"lint:fix": "openedx lint --fix .",
25-
"snapshot": "openedx test --updateSnapshot",
2625
"test": "openedx test --coverage --passWithNoTests"
2726
},
2827
"author": "Open edX",
@@ -37,7 +36,6 @@
3736
"dependencies": {
3837
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.3",
3938
"@edx/openedx-atlas": "^0.7.0",
40-
"@edx/react-unit-test-utils": "^4.0.0",
4139
"@fortawesome/fontawesome-svg-core": "^1.2.36",
4240
"@fortawesome/free-brands-svg-icons": "^5.15.4",
4341
"@fortawesome/free-solid-svg-icons": "^5.15.4",
@@ -59,6 +57,7 @@
5957
"@edx/browserslist-config": "^1.5.0",
6058
"@testing-library/jest-dom": "^6.6.3",
6159
"@testing-library/react": "^16.3.0",
60+
"@testing-library/user-event": "^14.6.1",
6261
"identity-obj-proxy": "^3.0.0",
6362
"jest": "^29.7.0",
6463
"jest-environment-jsdom": "^29.7.0",

src/__snapshots__/App.test.jsx.snap

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

src/__snapshots__/index.test.jsx.snap

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

src/components/Banner.test.jsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { shallow } from '@edx/react-unit-test-utils';
1+
import { render, screen } from '@testing-library/react';
2+
import Banner from './Banner';
23

3-
import { Alert } from '@openedx/paragon';
4+
describe('Banner component', () => {
5+
it('renders children content', () => {
6+
render(<Banner>Test content</Banner>);
7+
expect(screen.getByText('Test content')).toBeInTheDocument();
8+
});
49

5-
import Banner from './Banner';
10+
it('uses default props correctly', () => {
11+
render(<Banner>Test content</Banner>);
12+
const banner = screen.getByRole('alert');
13+
expect(banner).toHaveClass('mb-0');
14+
});
615

7-
describe('Banner', () => {
8-
const props = {
9-
children: 'Hello, world!',
10-
};
11-
describe('snapshot', () => {
12-
test('renders default banner', () => {
13-
const wrapper = shallow(<Banner {...props} />);
14-
expect(wrapper.snapshot).toMatchSnapshot();
15-
});
16-
test('renders with variants', () => {
17-
const wrapper = shallow(<Banner {...props} variant="success" />);
18-
expect(wrapper.snapshot).toMatchSnapshot();
16+
it('accepts custom variant prop', () => {
17+
render(<Banner variant="success">Test content</Banner>);
18+
const banner = screen.getByRole('alert');
19+
expect(banner).toHaveClass('alert-success');
20+
});
1921

20-
expect(wrapper.instance.findByType(Alert)[0].props.variant).toEqual('success');
21-
});
22-
test('renders with custom class', () => {
23-
const wrapper = shallow(<Banner {...props} className="custom-class" />);
24-
expect(wrapper.snapshot).toMatchSnapshot();
25-
});
22+
it('accepts custom className prop', () => {
23+
render(<Banner className="custom-class">Test content</Banner>);
24+
const banner = screen.getByRole('alert');
25+
expect(banner).toHaveClass('custom-class');
2626
});
2727
});

src/components/__snapshots__/Banner.test.jsx.snap

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

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

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

src/containers/CourseCard/components/CourseCardActions/ActionButton/__snapshots__/index.test.jsx.snap

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

src/containers/CourseCard/components/CourseCardActions/ActionButton/hooks.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
import { useWindowSize, breakpoints } from '@openedx/paragon';
22
import useIsCollapsed from './hooks';
33

4+
jest.mock('@openedx/paragon', () => ({
5+
...jest.requireActual('@openedx/paragon'),
6+
useWindowSize: jest.fn(),
7+
breakpoints: {
8+
extraSmall: {
9+
minWidth: 0,
10+
maxWidth: 575,
11+
},
12+
small: {
13+
minWidth: 576,
14+
maxWidth: 767,
15+
},
16+
medium: {
17+
minWidth: 768,
18+
maxWidth: 991,
19+
},
20+
large: {
21+
minWidth: 992,
22+
maxWidth: 1199,
23+
},
24+
extraLarge: {
25+
minWidth: 1200,
26+
maxWidth: 100000,
27+
},
28+
},
29+
}));
30+
431
describe('useIsCollapsed', () => {
532
it('returns true only when it is between medium and small', () => {
633
// make sure all three breakpoints gap is large enough for test

0 commit comments

Comments
 (0)