-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LayersControl does not pass map props to children (#142)
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Leaflet from 'leaflet'; | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
|
||
jest.autoMockOff(); | ||
|
||
const LayersControl = require('../src/LayersControl').default; | ||
const Map = require('../src/Map').default; | ||
|
||
describe('LayersControl', () => { | ||
it('passes its `map` prop to its children', () => { | ||
document.body.innerHTML = '<div id="test"></div>'; | ||
|
||
class ChildComponent extends React.Component { | ||
static propTypes = { | ||
map: React.PropTypes.instanceOf(Leaflet.Map) | ||
}; | ||
|
||
componentWillMount() { | ||
expect(this.props.map).toBeDefined(); | ||
} | ||
|
||
render() { | ||
return null; | ||
} | ||
} | ||
|
||
const component = ( | ||
<Map> | ||
<LayersControl> | ||
<LayersControl.Overlay checked name='test'> | ||
<ChildComponent /> | ||
</LayersControl.Overlay> | ||
</LayersControl> | ||
</Map> | ||
); | ||
|
||
render(component, document.getElementById('test')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters