MapComplete/test/integration/UnitHasSpace.spec.ts

22 lines
1 KiB
TypeScript
Raw Normal View History

import { describe, it } from "vitest"
import LayerConfig from "../../src/Models/ThemeConfig/LayerConfig"
import maxspeed_layer from "../../public/assets/generated/layers/maxspeed.json"
import { LayerConfigJson } from "../../src/Models/ThemeConfig/Json/LayerConfigJson"
import { expect } from "chai"
import { Tag } from "../../src/Logic/Tags/Tag"
describe("Integration_unit_has_space", () => {
it("maxspeed should produce '20 mph' and not '20mph'", () => {
const maxspeed = new LayerConfig(
<LayerConfigJson><any>maxspeed_layer, "integration_test"
)
const maxspeedQuestion = maxspeed.tagRenderings.find(tr => tr.id === "maxspeed-maxspeed")
const unit = maxspeed.units.find(unit => unit.appliesToKeys.has("maxspeed"))
const spec = maxspeedQuestion.constructChangeSpecification("20", undefined, undefined, {
"_country": "gb"
}, unit).find(t => t["key"] === "maxspeed")
expect(spec.asJson()).to.eq(new Tag("maxspeed", "20 mph").asJson())
})
})