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 { expect } from "chai"
|
||||
import { Utils } from "../../../Utils"
|
||||
import UserRelatedState from "../../../Logic/State/UserRelatedState"
|
||||
import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig"
|
||||
|
@ -11,6 +10,7 @@ import SelectedFeatureHandler from "../../../Logic/Actors/SelectedFeatureHandler
|
|||
import { ElementStorage } from "../../../Logic/ElementStorage"
|
||||
import { OsmTags } from "../../../Models/OsmFeature"
|
||||
import { Feature, Geometry } from "geojson"
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
const latestTags = {
|
||||
amenity: "public_bookcase",
|
||||
|
@ -83,9 +83,9 @@ it("should download the latest version", () => {
|
|||
SelectedElementTagsUpdater.applyUpdate(state, latestTags, feature.properties.id)
|
||||
|
||||
// The name should be updated
|
||||
expect(feature.properties.name).deep.equal("Stubbekwartier-buurtbibliotheek")
|
||||
expect(feature.properties.name).toEqual("Stubbekwartier-buurtbibliotheek")
|
||||
// The fixme should be removed
|
||||
expect(feature.properties.fixme).deep.equal(undefined)
|
||||
expect(feature.properties.fixme).toBeUndefined()
|
||||
})
|
||||
it("Hash without selected element should download geojson from OSM-API", async () => {
|
||||
const hash = new UIEventSource("node/5568693115")
|
||||
|
@ -97,9 +97,9 @@ it("Hash without selected element should download geojson from OSM-API", async (
|
|||
})
|
||||
|
||||
loc.addCallback((_) => {
|
||||
expect(selected.data.properties.id).deep.equal("node/5568693115")
|
||||
expect(loc.data.zoom).deep.equal(14)
|
||||
expect(loc.data.lat).deep.equal(51.2179199)
|
||||
expect(selected.data.properties.id).toEqual("node/5568693115")
|
||||
expect(loc.data.zoom).toEqual(14)
|
||||
expect(loc.data.lat).toEqual(51.2179199)
|
||||
})
|
||||
|
||||
new SelectedFeatureHandler(hash, {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { describe } from "mocha"
|
||||
import { expect } from "chai"
|
||||
import CreateMultiPolygonWithPointReuseAction from "../../../Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction"
|
||||
import { Tag } from "../../../Logic/Tags/Tag"
|
||||
import { Changes } from "../../../Logic/Osm/Changes"
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
describe("CreateMultiPolygonWithPointReuseAction", () => {
|
||||
it("should produce a correct changeset", () => {
|
||||
|
@ -106,21 +105,29 @@ describe("CreateMultiPolygonWithPointReuseAction", () => {
|
|||
const descriptions = await action.Perform(new Changes())
|
||||
|
||||
const ways = descriptions.filter((d) => d.type === "way")
|
||||
expect(ways[0].id == -18, "unexpected id").true
|
||||
expect(ways[1].id == -27, "unexpected id").true
|
||||
// "unexpected id"
|
||||
expect(ways[0].id == -18).toBe(true)
|
||||
// "unexpected id"
|
||||
expect(ways[1].id == -27).toBe(true)
|
||||
const outer = ways[0].changes["coordinates"]
|
||||
expect(outer).deep.equal(feature.geometry.coordinates[0])
|
||||
expect(outer).toEqual(feature.geometry.coordinates[0])
|
||||
const inner = ways[1].changes["coordinates"]
|
||||
expect(inner).deep.equal(feature.geometry.coordinates[1])
|
||||
expect(inner).toEqual(feature.geometry.coordinates[1])
|
||||
const members = <{ type: string; role: string; ref: number }[]>(
|
||||
descriptions.find((d) => d.type === "relation").changes["members"]
|
||||
)
|
||||
expect(members[0].role, "incorrect role").eq("outer")
|
||||
expect(members[1].role, "incorrect role").eq("inner")
|
||||
expect(members[0].type, "incorrect type").eq("way")
|
||||
expect(members[1].type, "incorrect type").eq("way")
|
||||
expect(members[0].ref, "incorrect id").eq(-18)
|
||||
expect(members[1].ref, "incorrect id").eq(-27)
|
||||
// "incorrect role"
|
||||
expect(members[0].role).toBe("outer")
|
||||
// "incorrect role"
|
||||
expect(members[1].role).toBe("inner")
|
||||
// "incorrect type"
|
||||
expect(members[0].type).toBe("way")
|
||||
// "incorrect type"
|
||||
expect(members[1].type).toBe("way")
|
||||
// "incorrect id"
|
||||
expect(members[0].ref).toBe(-18)
|
||||
// "incorrect id"
|
||||
expect(members[1].ref).toBe(-27)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue