forked from MapComplete/MapComplete
Port tests to vitest
This commit is contained in:
parent
64a4d7e929
commit
228ceb120d
33 changed files with 673 additions and 326 deletions
|
@ -1,4 +1,3 @@
|
|||
import { describe } from "mocha"
|
||||
import OsmFeatureSource from "../../../Logic/FeatureSource/TiledFeatureSource/OsmFeatureSource"
|
||||
import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||
import ScriptUtils from "../../../scripts/ScriptUtils"
|
||||
|
@ -8,7 +7,7 @@ import { readFileSync } from "fs"
|
|||
import { Utils } from "../../../Utils"
|
||||
import { Tag } from "../../../Logic/Tags/Tag"
|
||||
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
||||
import { expect } from "chai"
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
const expected = {
|
||||
type: "Feature",
|
||||
|
@ -92,7 +91,7 @@ function test(done: () => void) {
|
|||
handleTile: (tile) => {
|
||||
fetchedTile = tile
|
||||
const data = tile.features.data[0].feature
|
||||
expect(data.properties).deep.eq({
|
||||
expect(data.properties).toEqual({
|
||||
id: "relation/5759328",
|
||||
timestamp: "2022-06-10T00:46:55Z",
|
||||
version: 6,
|
||||
|
@ -107,8 +106,8 @@ function test(done: () => void) {
|
|||
website: "http://ktahalle.be/",
|
||||
_backend: "https://osm.org",
|
||||
})
|
||||
expect(data.geometry.type).eq("MultiPolygon")
|
||||
expect(data).deep.eq(expected)
|
||||
expect(data.geometry.type).toBe("MultiPolygon")
|
||||
expect(data).toEqual(expected)
|
||||
done()
|
||||
},
|
||||
isActive: new UIEventSource<boolean>(true),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { describe } from "mocha"
|
||||
import TileFreshnessCalculator from "../../../Logic/FeatureSource/TileFreshnessCalculator"
|
||||
import { Tiles } from "../../../Models/TileRange"
|
||||
import { expect } from "chai"
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
describe("TileFreshnessCalculator", () => {
|
||||
it("should get the freshness for loaded tiles", () => {
|
||||
|
@ -11,13 +10,13 @@ describe("TileFreshnessCalculator", () => {
|
|||
date.setTime(42)
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534), date)
|
||||
|
||||
expect(calc.freshnessFor(19, 266406, 175534).getTime()).eq(42)
|
||||
expect(calc.freshnessFor(20, 266406 * 2, 175534 * 2 + 1).getTime()).eq(42)
|
||||
expect(calc.freshnessFor(19, 266406, 175535)).undefined
|
||||
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2)).undefined
|
||||
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()
|
||||
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)
|
||||
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2).getTime()).eq(42)
|
||||
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2).getTime()).toBe(42)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue