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

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

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-07-15 18:55:03 +02:00
import { ChangeDescription } from "../../../src/Logic/Osm/Actions/ChangeDescription"
import { Changes } from "../../../src/Logic/Osm/Changes"
2023-02-03 04:48:32 +01:00
import { expect, it } from "vitest"
2023-07-15 18:55:03 +02:00
import { ImmutableStore } from "../../../src/Logic/UIEventSource"
import { OsmConnection } from "../../../src/Logic/Osm/OsmConnection"
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",
},
},
]
2023-05-17 13:16:43 +02:00
const c = new Changes({
dryRun: new ImmutableStore(true),
osmConnection: new OsmConnection(),
2023-05-17 13:16:43 +02:00
})
2022-03-17 21:51:53 +01:00
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
})