-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathindex.test.js
59 lines (48 loc) · 1.36 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
50
51
52
53
54
55
56
57
58
59
/* eslint-disable no-console */
import React from 'react';
import { mount } from 'enzyme';
import MapGL, { Marker } from '../..';
const Element = <div>ok</div>;
test('render', () => {
const onDragEnd = jest.fn();
const onDragStart = jest.fn();
const onDrag = jest.fn();
const wrapper = mount(
<MapGL latitude={0} longitude={0} zoom={0}>
<Marker
longitude={0}
latitude={0}
element={Element}
onDragEnd={onDragEnd}
onDragStart={onDragStart}
onDrag={onDrag}
/>
</MapGL>
);
const MarkerWrapper = wrapper.find('Marker');
expect(MarkerWrapper.exists()).toBe(true);
const marker = MarkerWrapper.instance().getMarker();
expect(marker).toBeTruthy();
wrapper.unmount();
expect(wrapper.find('Marker').exists()).toBe(false);
});
test('update', () => {
const wrapper = mount(
<MapGL latitude={0} longitude={0} zoom={0}>
<Marker longitude={0} latitude={0} element={Element} />
</MapGL>
);
wrapper.setProps({
children: <Marker longitude={1} latitude={0} element={Element} />
});
wrapper.setProps({
children: <Marker longitude={1} latitude={1} element={Element} />
});
});
test('throws', () => {
console.error = jest.fn();
expect(() =>
mount(<Marker longitude={0} latitude={0} element={Element} />)
).toThrow();
expect(console.error).toHaveBeenCalled();
});