forked from MapComplete/MapComplete
Fix: force a space between value and denomination (e.g. 20 mph
), add integration test for this
This commit is contained in:
parent
946439f8c3
commit
258cbe0802
4 changed files with 43 additions and 29 deletions
21
test/integration/UnitHasSpace.spec.ts
Normal file
21
test/integration/UnitHasSpace.spec.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
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())
|
||||
})
|
||||
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue