-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWindow.test.jsx
More file actions
99 lines (96 loc) · 2.99 KB
/
Window.test.jsx
File metadata and controls
99 lines (96 loc) · 2.99 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { MosaicWindowContext } from 'react-mosaic-component2';
import { render, screen } from '@tests/utils/test-utils';
import { Window } from '../../../src/components/Window';
/** create wrapper */
function createWrapper(props, state, renderOptions) {
return render(
<Window
windowId="xyz"
manifestId="foo"
classes={{}}
{...props}
/>,
{
preloadedState: {
windows: {
xyz: {
collectionDialogOn: false,
companionWindowIds: [],
},
},
},
},
{ renderOptions },
);
}
describe('Window', () => {
it('should render outer element', () => {
createWrapper();
expect(screen.getByLabelText('Window:')).toHaveClass('mirador-window');
});
it('should render <WindowTopBar>', () => {
createWrapper();
expect(screen.getByRole('navigation', { accessibleName: 'Window navigation' })).toBeInTheDocument();
});
it('should render <PrimaryWindow>', () => {
createWrapper();
expect(document.querySelector('.mirador-primary-window')).toBeInTheDocument(); // eslint-disable-line testing-library/no-node-access
});
// See ErrorContent.test.js for futher testing of this functionality
it('renders alert box when there is an error', async () => {
createWrapper({ manifestError: 'Invalid JSON' });
expect(screen.getByRole('alert')).toBeInTheDocument();
});
describe('when workspaceType is mosaic', () => {
it('calls the context mosaicWindowActions connectDragSource method to make WindowTopBar draggable', () => {
const connectDragSource = vi.fn(component => component);
render(
<MosaicWindowContext.Provider value={{ mosaicWindowActions: { connectDragSource } }}>
<Window
windowId="xyz"
manifestId="foo"
classes={{}}
windowDraggable
workspaceType="mosaic"
/>
</MosaicWindowContext.Provider>,
{
preloadedState: {
windows: {
xyz: {
collectionDialogOn: false,
companionWindowIds: [],
},
},
},
},
);
expect(connectDragSource).toHaveBeenCalled();
});
it('does not call the context mosaicWindowActions connectDragSource when the windowDraggable is set to false', () => {
const connectDragSource = vi.fn(component => component);
render(
<MosaicWindowContext.Provider value={{ mosaicWindowActions: { connectDragSource } }}>
<Window
windowId="xyz"
manifestId="foo"
classes={{}}
windowDraggable={false}
workspaceType="mosaic"
/>
</MosaicWindowContext.Provider>,
{
preloadedState: {
windows: {
xyz: {
collectionDialogOn: false,
companionWindowIds: [],
},
},
},
},
);
expect(connectDragSource).not.toHaveBeenCalled();
});
});
});