-
Notifications
You must be signed in to change notification settings - Fork 1
/
GoogleMap.test.jsx
68 lines (61 loc) · 1.85 KB
/
GoogleMap.test.jsx
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
/* global google */
import React, { Component } from 'react';
import { shallow, mount } from 'enzyme';
import { GoogleMap, GoogleMapWithLoader } from '../GoogleMap';
import { GoogleMapContext } from '../GoogleMapInitialzer';
class CWithMapAccess extends Component {
static contextType = GoogleMapContext;
render() {
return <div>Access to map instance using GoogleMapContext</div>;
}
}
describe('GoogleMap', () => {
it('has not changed', () => {
const props = {
google,
center: { lat: 0, lng: 0 },
zoom: 1,
height: 100,
width: 100,
};
const wrapper = shallow(<GoogleMap {...props}><div /></GoogleMap>);
expect(wrapper).toMatchSnapshot();
});
it('provides map instance to children components', () => {
const props = {
google,
center: { lat: 0, lng: 0 },
zoom: 1,
height: 100,
width: 100,
};
const wrapper = mount(<GoogleMap {...props}><CWithMapAccess /></GoogleMap>);
const instance = wrapper.find(CWithMapAccess).instance();
expect(instance.context.map).toBeInstanceOf(google.maps.Map);
});
});
describe('GoogleMapWithLoader', () => {
it('has not changed', () => {
const props = {
googleMapURL: '',
center: { lat: 0, lng: 0 },
zoom: 1,
height: 100,
width: 100,
};
const wrapper = shallow(<GoogleMapWithLoader {...props}><div /></GoogleMapWithLoader>);
expect(wrapper).toMatchSnapshot();
});
it('provides map instance to children components', () => {
const props = {
googleMapURL: '',
center: { lat: 0, lng: 0 },
zoom: 1,
height: 100,
width: 100,
};
const wrapper = mount(<GoogleMapWithLoader {...props}><CWithMapAccess /></GoogleMapWithLoader>);
const instance = wrapper.find(CWithMapAccess).instance();
expect(instance.context.map).toBeInstanceOf(google.maps.Map);
});
});