forked from MapComplete/MapComplete
First steps to a real testing framework: first working version with mocha, chai and doctest-ts
This commit is contained in:
parent
edc366149b
commit
4f4fc650b1
42 changed files with 9032 additions and 9275 deletions
51
testLegacy/Changes.spec.ts
Normal file
51
testLegacy/Changes.spec.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import T from "./TestHelper";
|
||||
import {Changes} from "../Logic/Osm/Changes";
|
||||
import {ChangeDescription, ChangeDescriptionTools} from "../Logic/Osm/Actions/ChangeDescription";
|
||||
|
||||
export default class ChangesSpec extends T {
|
||||
|
||||
constructor() {
|
||||
super([
|
||||
["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,
|
||||
[]
|
||||
)
|
||||
T.equals(0, descr.modifiedObjects.length)
|
||||
T.equals(0, descr.deletedObjects.length)
|
||||
T.equals(1, descr.newObjects.length)
|
||||
const ch = descr.newObjects[0]
|
||||
T.equals("bar", ch.tags["foo"])
|
||||
T.equals("someValue", ch.tags["someKey"])
|
||||
}]
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue