Skip to content

Commit

Permalink
v4 beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam committed Apr 18, 2022
1 parent 2c75fdd commit 55137ed
Show file tree
Hide file tree
Showing 18 changed files with 901 additions and 743 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v4.0.0-beta.1 (2022-04-18)

Updated Leaflet dependency to v1.8 beta.

## v4.0.0-beta.0 (2022-04-02)

Updated React dependencies to v18 stable.
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@
"devDependencies": {
"@skypack/package-check": "^0.2.2",
"@swc/cli": "^0.1.55",
"@swc/core": "^1.2.162",
"@swc/core": "^1.2.168",
"@swc/jest": "^0.2.17",
"@testing-library/react": "^13.0.0",
"@testing-library/react-hooks": "^8.0.0-alpha",
"@testing-library/react": "^13.1.1",
"@testing-library/react-hooks": "^8.0.0",
"@types/jest": "^27.4.0",
"@types/leaflet": "^1.7.9",
"@types/warning": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"cross-env": "^7.0.3",
"del-cli": "^4.0.1",
"eslint": "^8.11.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"jest": "^27.5.0",
"leaflet": "^1.7.1",
"prettier": "^2.5.1",
"leaflet": "^1.8.0-beta.3",
"prettier": "^2.6.2",
"prettier-eslint": "^13.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-test-renderer": "^18.0.0",
"ts-jest-resolver": "^2.0.0",
"turbo": "^1.1.6",
"turbo": "^1.2.4",
"typescript": "^4.5.5"
},
"jest": {
Expand Down
45 changes: 32 additions & 13 deletions packages/core/__tests__/components.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { act, render, screen } from '@testing-library/react'
import React, { useEffect, useRef } from 'react'
import React, { StrictMode, useEffect, useRef } from 'react'

import {
createElementHook,
Expand Down Expand Up @@ -28,7 +28,11 @@ describe('components', () => {
return <Component ref={ref} />
}

render(<TestWrapper />)
render(
<StrictMode>
<TestWrapper />
</StrictMode>,
)
expect(refInstance).toBe(instance)
})

Expand Down Expand Up @@ -98,9 +102,11 @@ describe('components', () => {
}

render(
<Component>
<Child />
</Component>,
<StrictMode>
<Component>
<Child />
</Component>
</StrictMode>,
)
expect(rendered).toBe(true)
})
Expand All @@ -123,9 +129,11 @@ describe('components', () => {
}

render(
<Component>
<Child />
</Component>,
<StrictMode>
<Component>
<Child />
</Component>
</StrictMode>,
)
expect(childContext).toBe(containerContext)
})
Expand All @@ -146,7 +154,11 @@ describe('components', () => {
return <Component ref={ref} />
}

render(<TestWrapper />)
render(
<StrictMode>
<TestWrapper />
</StrictMode>,
)
expect(refInstance).toBe(instance)
})

Expand All @@ -173,9 +185,11 @@ describe('components', () => {
const useOverlay = createDivOverlayHook(useElement, jest.fn())
const Component = createDivOverlayComponent(useOverlay)
render(
<Component>
<span>Test</span>
</Component>,
<StrictMode>
<Component>
<span>Test</span>
</Component>
</StrictMode>,
{ wrapper: createWrapper({}) },
)
screen.getByText('Test')
Expand All @@ -195,7 +209,12 @@ describe('components', () => {

const useOverlay = createDivOverlayHook(useElement, useLifecycle)
const Component = createDivOverlayComponent(useOverlay)
render(<Component />, { wrapper: createWrapper({}) })
render(
<StrictMode>
<Component />
</StrictMode>,
{ wrapper: createWrapper({}) },
)

expect(update).not.toHaveBeenCalled()
act(() => {
Expand Down
8 changes: 6 additions & 2 deletions packages/core/__tests__/context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderHook } from '@testing-library/react-hooks'
import type { Map } from 'leaflet'
import React, { type ReactNode } from 'react'
import React, { StrictMode, type ReactNode } from 'react'

import {
CONTEXT_VERSION,
Expand All @@ -11,7 +11,11 @@ import {

export function createWrapper(context) {
return function Wrapper({ children }: { children: ReactNode }) {
return <LeafletProvider value={context}>{children}</LeafletProvider>
return (
<StrictMode>
<LeafletProvider value={context}>{children}</LeafletProvider>
</StrictMode>
)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-leaflet/core",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"description": "React Leaflet core",
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,7 +41,7 @@
"prepublishOnly": "package-check"
},
"peerDependencies": {
"leaflet": "^1.7.1",
"leaflet": "^1.8.0-beta.3",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
Expand Down
8 changes: 6 additions & 2 deletions packages/react-leaflet/__tests__/MapContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { render } from '@testing-library/react'
import { type LatLngExpression, Map } from 'leaflet'
import React, { useEffect, useRef } from 'react'
import React, { StrictMode, useEffect, useRef } from 'react'

import { MapContainer, useMap } from '../src'

describe('MapContainer', () => {
test('renders the containing div', () => {
const { container } = render(<MapContainer center={[0, 0]} zoom={10} />)
const { container } = render(
<StrictMode>
<MapContainer center={[0, 0]} zoom={10} />
</StrictMode>,
)
expect(container).toMatchSnapshot()
})

Expand Down
60 changes: 34 additions & 26 deletions packages/react-leaflet/__tests__/Pane.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react'
import React, { useEffect, useRef } from 'react'
import React, { StrictMode, useEffect, useRef } from 'react'

import { MapContainer, Pane, TileLayer } from '../src'

Expand All @@ -17,20 +17,20 @@ describe('Pane', () => {

test('renders in Strict Mode', () => {
const { container } = render(
<React.StrictMode>
<StrictMode>
<MapContainer center={[0, 0]} zoom={10}>
<Pane name="foo" style={{ zIndex: 1001 }}>
<TileLayer attribution="tiles attribution" url="http://localhost" />
</Pane>
</MapContainer>
</React.StrictMode>,
</StrictMode>,
)
expect(container).toMatchSnapshot()
})

test('renders nested panes', () => {
const { container } = render(
<React.StrictMode>
<StrictMode>
<MapContainer center={[0, 0]} zoom={10}>
<Pane name="foo" style={{ zIndex: 1001 }}>
<Pane name="bar" style={{ zIndex: 4000 }}>
Expand All @@ -45,48 +45,56 @@ describe('Pane', () => {
/>
</Pane>
</MapContainer>
</React.StrictMode>,
</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 }}>
<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/nested"
url="http://localhost/not-nested"
/>
</Pane>
<TileLayer
attribution="tiles attribution"
url="http://localhost/not-nested"
/>
</Pane>
</MapContainer>,
</MapContainer>
</StrictMode>,
)
expect(container).toMatchSnapshot()

rerender(<MapContainer center={[0, 0]} zoom={10}></MapContainer>)
rerender(
<StrictMode>
<MapContainer center={[0, 0]} zoom={10}></MapContainer>
</StrictMode>,
)
expect(container).toMatchSnapshot()

rerender(
<MapContainer center={[0, 0]} zoom={10}>
<Pane name="bar" style={{ zIndex: 1001 }}>
<Pane name="foo" style={{ zIndex: 4000 }}>
<StrictMode>
<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-foo-nested"
url="http://localhost/new-bar-not-nested"
/>
</Pane>
<TileLayer
attribution="tiles attribution"
url="http://localhost/new-bar-not-nested"
/>
</Pane>
</MapContainer>,
</MapContainer>
</StrictMode>,
)
expect(container).toMatchSnapshot()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`AttributionControl renders and unmounts 1`] = `
<div>
<div
class="leaflet-container leaflet-grab leaflet-touch-drag"
class="leaflet-container leaflet-touch leaflet-grab leaflet-touch-drag leaflet-touch-zoom"
style="position: relative;"
tabindex="0"
>
Expand All @@ -15,10 +15,10 @@ exports[`AttributionControl renders and unmounts 1`] = `
class="leaflet-pane leaflet-tile-pane"
/>
<div
class="leaflet-pane leaflet-shadow-pane"
class="leaflet-pane leaflet-overlay-pane"
/>
<div
class="leaflet-pane leaflet-overlay-pane"
class="leaflet-pane leaflet-shadow-pane"
/>
<div
class="leaflet-pane leaflet-marker-pane"
Expand All @@ -40,22 +40,32 @@ exports[`AttributionControl renders and unmounts 1`] = `
class="leaflet-control-zoom leaflet-bar leaflet-control"
>
<a
aria-disabled="false"
aria-label="Zoom in"
class="leaflet-control-zoom-in"
href="#"
role="button"
title="Zoom in"
>
+
<span
aria-hidden="true"
>
+
</span>
</a>
<a
aria-disabled="false"
aria-label="Zoom out"
class="leaflet-control-zoom-out"
href="#"
role="button"
title="Zoom out"
>
<span
aria-hidden="true"
>
</span>
</a>
</div>
</div>
Expand All @@ -70,7 +80,7 @@ exports[`AttributionControl renders and unmounts 1`] = `
>
<a
href="https://leafletjs.com"
title="A JS library for interactive maps"
title="A JavaScript library for interactive maps"
>
Leaflet
</a>
Expand All @@ -84,7 +94,7 @@ exports[`AttributionControl renders and unmounts 1`] = `
>
<a
href="https://leafletjs.com"
title="A JS library for interactive maps"
title="A JavaScript library for interactive maps"
>
Leaflet
</a>
Expand Down
Loading

0 comments on commit 55137ed

Please sign in to comment.