mapcomplete/test/Logic/FeatureSource/TileFreshnessCalculator.spec.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-03-15 01:53:08 +01:00
import TileFreshnessCalculator from "../../../Logic/FeatureSource/TileFreshnessCalculator"
import { Tiles } from "../../../Models/TileRange"
2023-02-03 04:48:32 +01:00
import { describe, expect, it } from "vitest"
2022-03-15 01:53:08 +01:00
describe("TileFreshnessCalculator", () => {
it("should get the freshness for loaded tiles", () => {
const calc = new TileFreshnessCalculator()
// 19/266407/175535
const date = new Date()
date.setTime(42)
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534), date)
2023-02-03 04:48:32 +01:00
expect(calc.freshnessFor(19, 266406, 175534).getTime()).toBe(42)
expect(calc.freshnessFor(20, 266406 * 2, 175534 * 2 + 1).getTime()).toBe(42)
expect(calc.freshnessFor(19, 266406, 175535)).toBeUndefined()
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2)).toBeUndefined()
2022-03-15 01:53:08 +01:00
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534 + 1), date)
calc.addTileLoad(Tiles.tile_index(19, 266406 + 1, 175534), date)
calc.addTileLoad(Tiles.tile_index(19, 266406 + 1, 175534 + 1), date)
2023-02-03 04:48:32 +01:00
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2).getTime()).toBe(42)
2022-03-15 01:53:08 +01:00
})
})