mapcomplete/test/Logic/OSM/Changes.spec.ts

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

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-03-17 21:51:53 +01:00
import { ChangeDescription } from "../../../Logic/Osm/Actions/ChangeDescription"
import { Changes } from "../../../Logic/Osm/Changes"
2023-02-03 04:48:32 +01:00
import { expect, it } from "vitest"
2022-03-17 21:51:53 +01:00
it("Generate preXML from changeDescriptions", () => {
const changeDescrs: ChangeDescription[] = [
{
type: "node",
id: -1,
changes: {
lat: 42,
lon: -8,
},
tags: [{ k: "someKey", v: "someValue" }],
meta: {
changeType: "create",
theme: "test",
},
},
{
type: "node",
id: -1,
tags: [{ k: "foo", v: "bar" }],
meta: {
changeType: "answer",
theme: "test",
},
},
]
const c = new Changes()
const descr = c.CreateChangesetObjects(changeDescrs, [])
2023-02-03 04:48:32 +01:00
expect(descr.modifiedObjects).toHaveLength(0)
expect(descr.deletedObjects).toHaveLength(0)
expect(descr.newObjects).toHaveLength(1)
2022-03-17 21:51:53 +01:00
const ch = descr.newObjects[0]
2023-02-03 04:48:32 +01:00
expect(ch.tags["foo"]).toBe("bar")
expect(ch.tags["someKey"]).toBe("someValue")
2022-03-17 21:51:53 +01:00
})