MapComplete/test/integration/UnitHasSpace.spec.ts

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

27 lines
1.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'", () => {
2025-09-07 22:49:44 +02:00
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())
})
})