-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathErrorContent.test.jsx
More file actions
61 lines (60 loc) · 1.64 KB
/
ErrorContent.test.jsx
File metadata and controls
61 lines (60 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { render, screen } from '@tests/utils/test-utils';
import { ErrorContent } from '../../../src/components/ErrorContent';
describe('ErrorContent', () => {
it('should render everything when showJsError is true', async () => {
render(
<ErrorContent
error={new Error('Invalid JSON')}
windowId="xyz"
manifestId="foo"
classes={{}}
/>,
{
preloadedState: {
config: {
window: {
showJsError: true,
},
},
windows: {
xyz: {
collectionDialogOn: false,
companionWindowIds: [],
},
},
},
},
);
expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.getByText('An error occurred')).toBeInTheDocument();
expect(screen.getByText('Technical details')).toBeInTheDocument();
expect(document.querySelector('pre')).toHaveTextContent('Invalid JSON'); // eslint-disable-line testing-library/no-node-access
});
it('does not render the alert when showJsError is false ', async () => {
render(
<ErrorContent
error={new Error('Invalid JSON')}
windowId="xyz"
manifestId="foo"
showJsError={false}
classes={{}}
/>,
{
preloadedState: {
config: {
window: {
showJsError: false,
},
},
windows: {
xyz: {
collectionDialogOn: false,
companionWindowIds: [],
},
},
},
},
);
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
});
});