Skip to content

Commit

Permalink
Unit tests for enumerateTilesAround
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Nov 25, 2024
1 parent f928de0 commit 8297fc8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/composables/tile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from "chai";
import {
createBoundingBox,
latLonToTileCoords,
enumerateTilesAround,
} from "./tile";

describe("createBoundingBox", () => {
Expand Down Expand Up @@ -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);
});
})

0 comments on commit 8297fc8

Please sign in to comment.