Testing negative indices fot TiledLayer components.
This commit is contained in:
parent
0d927c72cd
commit
16097c1e2e
|
@ -1,4 +1,4 @@
|
||||||
import { render, screen } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
import TiledLayer from './TiledLayer';
|
import TiledLayer from './TiledLayer';
|
||||||
import { TileFactory } from './types';
|
import { TileFactory } from './types';
|
||||||
|
|
||||||
|
@ -170,4 +170,81 @@ describe('The TiledLayer component ', () => {
|
||||||
</body>
|
</body>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
test('Also works with negative coordinates', () => {
|
||||||
|
const { baseElement } = render(
|
||||||
|
<svg>
|
||||||
|
<TiledLayer
|
||||||
|
keyObject={{ provider: 'osm', zoomLevel: 10, x: 5, y: 8 }}
|
||||||
|
viewPort={{ topLeft: { x: -3, y: -1 }, bottomRight: { x: -2, y: 2 } }}
|
||||||
|
tileFactory={fakeTileFactory}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
// screen.debug();
|
||||||
|
expect(baseElement).toMatchInlineSnapshot(`
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<svg>
|
||||||
|
<g
|
||||||
|
transform="translate(-3, -1)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":2,"y":4}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-2, -1)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":3,"y":4}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-3, 0)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":2,"y":5}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-2, 0)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":3,"y":5}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-3, 1)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":2,"y":6}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-2, 1)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":3,"y":6}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-3, 2)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":2,"y":7}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(-2, 2)"
|
||||||
|
>
|
||||||
|
<text>
|
||||||
|
{"provider":"osm","zoomLevel":10,"x":3,"y":7}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,6 +24,8 @@ export interface TiledLayerProperties {
|
||||||
* This component has no need to know the number nor the size of its tiles: tiles can be added when needed and
|
* This component has no need to know the number nor the size of its tiles: tiles can be added when needed and
|
||||||
* its unit is the tile size (the parent component needs to transform its enclosing SVG group to adapt its units)
|
* its unit is the tile size (the parent component needs to transform its enclosing SVG group to adapt its units)
|
||||||
*
|
*
|
||||||
|
* TODO: test tiles'X and Y boundaries.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
export const TiledLayer: react.FC<TiledLayerProperties> = (
|
export const TiledLayer: react.FC<TiledLayerProperties> = (
|
||||||
props: TiledLayerProperties
|
props: TiledLayerProperties
|
||||||
|
|
Loading…
Reference in New Issue