forked from PaulLeCam/react-leaflet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapLayer.js
48 lines (40 loc) · 1.06 KB
/
MapLayer.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
/* global describe, expect, it, jest */
import React, { Component } from 'react'
import { renderIntoDocument } from 'react-dom/test-utils'
import { Map, MapLayer, withLeaflet } from '../src'
describe('MapLayer', () => {
it('injects the `leaflet` context if provided', () => {
const mockElement = jest.fn()
class TestComponent extends MapLayer {
constructor(props) {
super(props)
expect(props.leaflet.popupContainer).not.toBeDefined()
this.contextValue = {
...props.leaflet,
popupContainer: this.leafletElement,
}
}
createLeafletElement() {
return mockElement
}
}
const Test = withLeaflet(TestComponent)
class ChildComponent extends Component {
constructor(props) {
super(props)
expect(props.leaflet.popupContainer).toBe(mockElement)
}
render() {
return null
}
}
const Child = withLeaflet(ChildComponent)
renderIntoDocument(
<Map>
<Test>
<Child />
</Test>
</Map>,
)
})
})