Skip to content

Commit 2fe24f3

Browse files
test: replacing snapshot tests with RTL tests part 13 (#2233)
1 parent c4f565b commit 2fe24f3

File tree

14 files changed

+189
-871
lines changed

14 files changed

+189
-871
lines changed

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/HandoutWidget/__snapshots__/index.test.jsx.snap

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

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/HandoutWidget/index.test.jsx

Lines changed: 0 additions & 81 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import { render, screen, initializeMocks } from '@src/testUtils';
3+
import { formatMessage } from '@src/editors/testUtils';
4+
import { HandoutWidgetInternal as HandoutWidget } from '.';
5+
6+
jest.mock('@src/editors/data/redux', () => ({
7+
actions: {
8+
video: {
9+
updateField: jest.fn().mockName('actions.video.updateField'),
10+
},
11+
},
12+
selectors: {
13+
video: {
14+
getHandoutDownloadUrl: jest.fn(args => ({ getHandoutDownloadUrl: args })).mockName('selectors.video.getHandoutDownloadUrl'),
15+
handout: jest.fn(state => ({ handout: state })),
16+
},
17+
app: {
18+
isLibrary: jest.fn(args => ({ isLibrary: args })),
19+
},
20+
requests: {
21+
isFailed: jest.fn(args => ({ isFailed: args })),
22+
},
23+
},
24+
}));
25+
26+
describe('HandoutWidget', () => {
27+
const props = {
28+
intl: { formatMessage },
29+
isLibrary: false,
30+
handout: '',
31+
isUploadError: false,
32+
getHandoutDownloadUrl: jest.fn().mockName('args.getHandoutDownloadUrl'),
33+
updateField: jest.fn().mockName('args.updateField'),
34+
};
35+
36+
describe('renders', () => {
37+
beforeEach(() => {
38+
initializeMocks();
39+
});
40+
test('renders as expected with default props', () => {
41+
render(<HandoutWidget {...props} />);
42+
expect(screen.getByText('Handout')).toBeInTheDocument();
43+
expect(screen.getByRole('button', { name: 'Upload Handout' })).toBeInTheDocument();
44+
expect(screen.getByRole('button', { name: 'Handout' })).toBeInTheDocument();
45+
expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();
46+
});
47+
test('renders as expected with isLibrary true', () => {
48+
const { container } = render(<HandoutWidget {...props} isLibrary />);
49+
const reduxWrapper = container.firstChild;
50+
expect(reduxWrapper?.textContent).toBe('');
51+
expect(screen.queryByText('Handout')).not.toBeInTheDocument();
52+
});
53+
test('renders as expected with handout', () => {
54+
const handoutUrl = 'sOMeUrl ';
55+
render(<HandoutWidget {...props} handout={handoutUrl} />);
56+
expect(screen.getByText('Handout')).toBeInTheDocument();
57+
expect(screen.getByText(handoutUrl.trim())).toBeInTheDocument();
58+
});
59+
});
60+
});

src/editors/sharedComponents/CodeEditor/__snapshots__/index.test.jsx.snap

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

0 commit comments

Comments
 (0)