-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathindex.test.js
49 lines (38 loc) · 1.22 KB
/
index.test.js
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
/* eslint-disable no-console */
import React from 'react';
import { mount } from 'enzyme';
import MapGL, { Source, FeatureState } from '../..';
test('render', () => {
const data = { type: 'FeatureCollection', features: [] };
const wrapper = mount(
<MapGL latitude={0} longitude={0} zoom={0}>
<Source id="test" type="geojson" data={data} />
<FeatureState id="test" source="test" />
</MapGL>
);
expect(wrapper.find('FeatureState').exists()).toBe(true);
wrapper.unmount();
expect(wrapper.find('FeatureState').exists()).toBe(false);
});
test('update', () => {
const data = { type: 'FeatureCollection', features: [] };
const wrapper = mount(
<MapGL latitude={0} longitude={0} zoom={0}>
<Source id="test" type="geojson" data={data} />
<FeatureState id="test" source="test" state={{ hover: false }} />
</MapGL>
);
wrapper.setProps({
children: [
<Source id="test" type="geojson" data={data} />,
<FeatureState id="test" source="test" state={{ hover: true }} />
]
});
});
test('throws', () => {
console.error = jest.fn();
expect(() =>
mount(<FeatureState id="test" source="test" state={{}} />)
).toThrow();
expect(console.error).toHaveBeenCalled();
});