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

40 lines
1.1 KiB
TypeScript
Raw Normal View History

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