From 8297fc87b8b3c766ede798d129dcfb7abb04b060 Mon Sep 17 00:00:00 2001 From: "Daniel W. Steinbrook" Date: Sun, 24 Nov 2024 20:37:16 -0500 Subject: [PATCH] Unit tests for enumerateTilesAround --- src/composables/tile.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/composables/tile.test.ts b/src/composables/tile.test.ts index ee393f3..012f0c2 100644 --- a/src/composables/tile.test.ts +++ b/src/composables/tile.test.ts @@ -2,6 +2,7 @@ import { expect } from "chai"; import { createBoundingBox, latLonToTileCoords, + enumerateTilesAround, } from "./tile"; describe("createBoundingBox", () => { @@ -38,3 +39,23 @@ describe("latLonToTileCoords", () => { expect(result).to.deep.equal({ x: 6, y: 4, z: 3 }); }); }); + +describe("enumerateTilesAround", () => { + it('should return tiles around location', () => { + // 10m radius around Washington Monument + const result = enumerateTilesAround(38.889444, -77.035278, 10) + expect(result.length).to.equal(1); + expect(result[0]).to.include({ + x: 18744, + y: 25072, + z: 16, + key: '16/18744/25072', + }); + }); + + it('should return more tiles for a bigger radius', () => { + // 1km radius around Washington Monument + const result = enumerateTilesAround(38.889444, -77.035278, 1000) + expect(result.length).to.equal(25); + }); +}) \ No newline at end of file