From 16097c1e2e01d1034d4b378525d3463a4edd807d Mon Sep 17 00:00:00 2001 From: evlist Date: Mon, 17 Oct 2022 23:04:58 +0200 Subject: [PATCH] Testing negative indices fot TiledLayer components. --- src/components/map/TiledLayer.test.tsx | 79 +++++++++++++++++++++++++- src/components/map/TiledLayer.tsx | 2 + 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/src/components/map/TiledLayer.test.tsx b/src/components/map/TiledLayer.test.tsx index edcd89f..e5c58ef 100644 --- a/src/components/map/TiledLayer.test.tsx +++ b/src/components/map/TiledLayer.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { render } from '@testing-library/react'; import TiledLayer from './TiledLayer'; import { TileFactory } from './types'; @@ -170,4 +170,81 @@ describe('The TiledLayer component ', () => { `); }); + test('Also works with negative coordinates', () => { + const { baseElement } = render( + + + + ); + // screen.debug(); + expect(baseElement).toMatchInlineSnapshot(` + +
+ + + + {"provider":"osm","zoomLevel":10,"x":2,"y":4} + + + + + {"provider":"osm","zoomLevel":10,"x":3,"y":4} + + + + + {"provider":"osm","zoomLevel":10,"x":2,"y":5} + + + + + {"provider":"osm","zoomLevel":10,"x":3,"y":5} + + + + + {"provider":"osm","zoomLevel":10,"x":2,"y":6} + + + + + {"provider":"osm","zoomLevel":10,"x":3,"y":6} + + + + + {"provider":"osm","zoomLevel":10,"x":2,"y":7} + + + + + {"provider":"osm","zoomLevel":10,"x":3,"y":7} + + + +
+ +`); + }); + }); diff --git a/src/components/map/TiledLayer.tsx b/src/components/map/TiledLayer.tsx index 5de7820..8269c48 100644 --- a/src/components/map/TiledLayer.tsx +++ b/src/components/map/TiledLayer.tsx @@ -23,6 +23,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 * 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 = (