-
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.
Make Pane component compatible with StrictMode (#810)
- Loading branch information
Showing
3 changed files
with
944 additions
and
4 deletions.
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,78 @@ | ||
import { render } from '@testing-library/react' | ||
import React from 'react' | ||
|
||
import { MapContainer, Pane, TileLayer } from '../src' | ||
|
||
describe('Pane', () => { | ||
test('renders', () => { | ||
const { container } = render( | ||
<MapContainer center={[0, 0]} zoom={10}> | ||
<Pane name="foo" style={{ zIndex: 1000 }}> | ||
<TileLayer attribution="tiles attribution" url="http://localhost" /> | ||
</Pane> | ||
</MapContainer>, | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('renders in Strict Mode', () => { | ||
const { container } = render( | ||
<React.StrictMode> | ||
<MapContainer center={[0, 0]} zoom={10}> | ||
<Pane name="foo" style={{ zIndex: 1001 }}> | ||
<TileLayer attribution="tiles attribution" url="http://localhost" /> | ||
</Pane> | ||
</MapContainer> | ||
</React.StrictMode>, | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('renders nested panes', () => { | ||
const { container } = render( | ||
<React.StrictMode> | ||
<MapContainer center={[0, 0]} zoom={10}> | ||
<Pane name="foo" style={{ zIndex: 1001 }}> | ||
<Pane name="bar" style={{ zIndex: 4000 }}> | ||
<TileLayer attribution="tiles attribution" url="http://localhost/nested" /> | ||
</Pane> | ||
<TileLayer attribution="tiles attribution" url="http://localhost/not-nested" /> | ||
</Pane> | ||
</MapContainer> | ||
</React.StrictMode>, | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('can unmount and remount with the same name', () => { | ||
const { rerender, container } = render( | ||
<MapContainer center={[0, 0]} zoom={10}> | ||
<Pane name="foo" style={{ zIndex: 1001 }}> | ||
<Pane name="bar" style={{ zIndex: 4000 }}> | ||
<TileLayer attribution="tiles attribution" url="http://localhost/nested" /> | ||
</Pane> | ||
<TileLayer attribution="tiles attribution" url="http://localhost/not-nested" /> | ||
</Pane> | ||
</MapContainer>, | ||
) | ||
expect(container).toMatchSnapshot() | ||
|
||
rerender( | ||
<MapContainer center={[0, 0]} zoom={10}> | ||
</MapContainer>, | ||
) | ||
expect(container).toMatchSnapshot() | ||
|
||
rerender( | ||
<MapContainer center={[0, 0]} zoom={10}> | ||
<Pane name="bar" style={{ zIndex: 1001 }}> | ||
<Pane name="foo" style={{ zIndex: 4000 }}> | ||
<TileLayer attribution="tiles attribution" url="http://localhost/new-foo-nested" /> | ||
</Pane> | ||
<TileLayer attribution="tiles attribution" url="http://localhost/new-bar-not-nested" /> | ||
</Pane> | ||
</MapContainer> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
}) |
Oops, something went wrong.