-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathWindowCanvasNavigationControls.test.jsx
More file actions
44 lines (39 loc) · 1.89 KB
/
WindowCanvasNavigationControls.test.jsx
File metadata and controls
44 lines (39 loc) · 1.89 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
import { render, screen } from '@tests/utils/test-utils';
import { WindowCanvasNavigationControls } from '../../../src/components/WindowCanvasNavigationControls';
/**
* create a simple wrapper for rendering our component
*/
function Subject({ ...props }) {
return (
<WindowCanvasNavigationControls
canvases={[]}
canvasLabel="label"
windowId="abc"
zoomToWorld={vi.fn()}
{...props}
/>
);
}
describe('WindowCanvasNavigationControls', () => {
it('renders properly', async () => {
const { container } = render(<Subject />);
expect(screen.getByLabelText('Previous item', { selector: 'button' })).toBeInTheDocument();
expect(screen.getByLabelText('Next item', { selector: 'button' })).toBeInTheDocument();
expect(screen.getByText(/1 of/)).toBeInTheDocument();
expect(container.firstChild).not.toHaveClass('mirador-canvas-nav-stacked'); // eslint-disable-line testing-library/no-node-access
});
it('renders only a screen-reader accessibile version when visible=false', () => {
const { container } = render(<Subject visible={false} />);
expect(container.firstChild).toHaveStyle({ height: '1px', margin: '-1px', width: '1px' }); // eslint-disable-line testing-library/no-node-access
});
it.skip('stacks the nav controls on small width screens', () => {
const { container } = render(<div style={{ position: 'relative', width: 252 }}><Subject /></div>);
expect(container.firstChild).toHaveClass('mirador-canvas-nav-stacked'); // eslint-disable-line testing-library/no-node-access
});
it('shows the zoom control component when specified', () => {
render(<Subject showZoomControls />);
expect(screen.getByRole('button', { name: 'Zoom in' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Zoom out' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Reset zoom' })).toBeInTheDocument();
});
});