forked from terrestris/react-geo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeLayerSliderPanel.spec.tsx
More file actions
74 lines (63 loc) · 1.95 KB
/
TimeLayerSliderPanel.spec.tsx
File metadata and controls
74 lines (63 loc) · 1.95 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
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import dayjs from 'dayjs';
import OlLayerTile from 'ol/layer/Tile';
import OlMap from 'ol/Map';
import OlSourceTileWMS from 'ol/source/TileWMS';
import * as React from 'react';
import TestUtil from '../../Util/TestUtil';
import TimeLayerSliderPanel from '../TimeLayerSliderPanel/TimeLayerSliderPanel';
describe('<TimeLayerSliderPanel />', () => {
let map: OlMap;
const testLayerName = 'OSM-WMS';
const testLayerTitle = 'OSM-WMS - by terrestris';
const testLayer = new OlLayerTile({
visible: false,
source: new OlSourceTileWMS({
url: 'https://ows.terrestris.de/osm/service?',
params: {
LAYERS: testLayerName,
TILED: true
}
}),
properties: {
title: testLayerTitle
}
});
beforeEach(() => {
map = TestUtil.createMap();
map.addLayer(testLayer);
});
it('is defined', () => {
expect(TimeLayerSliderPanel).not.toBeUndefined();
});
it('can be rendered', () => {
const { container } = render(<TimeLayerSliderPanel
min={dayjs().subtract(3, 'hours')}
max={dayjs()}
timeAwareLayers={[]}
/>);
expect(container).toBeVisible();
});
it('autoplay button is visible', () => {
render(<TimeLayerSliderPanel
min={dayjs().subtract(3, 'hours')}
max={dayjs()}
timeAwareLayers={[]}
/>);
const playButton = screen.getByLabelText('Autoplay');
expect(playButton).toBeVisible();
});
it('autoplay can be toggled', async () => {
render(<TimeLayerSliderPanel
min={dayjs().subtract(3, 'hours')}
max={dayjs()}
timeAwareLayers={[testLayer]}
/>);
const playButton = screen.getByLabelText('Autoplay');
expect(playButton).toHaveAttribute('aria-pressed', 'false');
await userEvent.click(playButton);
expect(playButton).toHaveAttribute('aria-pressed', 'true');
expect(playButton).toBeVisible();
});
});