Rename tests to test; add a few tests
This commit is contained in:
parent
df706d2f97
commit
c3859d56c6
28 changed files with 33 additions and 5 deletions
|
@ -24,7 +24,7 @@ function detectInCode(forbidden: string, reason: string) {
|
|||
throw stderr
|
||||
}
|
||||
|
||||
const found = stdout.split("\n").filter(s => s !== "").filter(s => !s.startsWith("./tests/") && !s.startsWith("./testLegacy/"));
|
||||
const found = stdout.split("\n").filter(s => s !== "").filter(s => !s.startsWith("./test/"));
|
||||
if (found.length > 0) {
|
||||
throw `Found a '${forbidden}' at \n ${found.join("\n ")}.\n ${reason}`
|
||||
}
|
|
@ -12,9 +12,6 @@ import RewritableConfigJson from "../../../../Models/ThemeConfig/Json/Rewritable
|
|||
|
||||
describe("ExpandRewrite", () => {
|
||||
|
||||
it("should do simple substitution", () => {
|
||||
|
||||
})
|
||||
it("should not allow overlapping keys", () => {
|
||||
const spec = <RewritableConfigJson<string>>{
|
||||
rewrite: {
|
|
@ -9,6 +9,7 @@ import * as bookcaseLayer from "../../../../assets/generated/layers/public_bookc
|
|||
import LayerConfig from "../../../../Models/ThemeConfig/LayerConfig";
|
||||
import {ExtractImages} from "../../../../Models/ThemeConfig/Conversion/FixImages";
|
||||
import * as cyclofix from "../../../../assets/generated/themes/cyclofix.json"
|
||||
import {Tag} from "../../../../Logic/Tags/Tag";
|
||||
|
||||
|
||||
const themeConfigJson: LayoutConfigJson = {
|
||||
|
@ -38,7 +39,23 @@ const themeConfigJson: LayoutConfigJson = {
|
|||
|
||||
describe("PrepareTheme", () => {
|
||||
|
||||
it("should apply overrideAll", () => {
|
||||
it("should substitute layers", () => {
|
||||
|
||||
const sharedLayers = new Map<string, LayerConfigJson>()
|
||||
sharedLayers.set("public_bookcase", bookcaseLayer["default"])
|
||||
const theme ={...themeConfigJson, layers: ["public_bookcase"]}
|
||||
const prepareStep = new PrepareTheme({
|
||||
tagRenderings: new Map<string, TagRenderingConfigJson>(),
|
||||
sharedLayers: sharedLayers
|
||||
})
|
||||
let themeConfigJsonPrepared = prepareStep.convert(theme, "test").result
|
||||
const themeConfig = new LayoutConfig(themeConfigJsonPrepared);
|
||||
const layerUnderTest = <LayerConfig> themeConfig.layers.find(l => l.id === "public_bookcase")
|
||||
expect(layerUnderTest.source.osmTags).deep.eq(new Tag("amenity","public_bookcase"))
|
||||
|
||||
})
|
||||
|
||||
it("should apply override", () => {
|
||||
|
||||
const sharedLayers = new Map<string, LayerConfigJson>()
|
||||
sharedLayers.set("public_bookcase", bookcaseLayer["default"])
|
||||
|
@ -51,6 +68,20 @@ describe("PrepareTheme", () => {
|
|||
expect(layerUnderTest.source.geojsonSource).eq("xyz")
|
||||
|
||||
})
|
||||
|
||||
|
||||
it("should apply override", () => {
|
||||
|
||||
const sharedLayers = new Map<string, LayerConfigJson>()
|
||||
sharedLayers.set("public_bookcase", bookcaseLayer["default"])
|
||||
let themeConfigJsonPrepared = new PrepareTheme({
|
||||
tagRenderings: new Map<string, TagRenderingConfigJson>(),
|
||||
sharedLayers: sharedLayers
|
||||
}).convert({...themeConfigJson, overrideAll: {source: {geoJson: "https://example.com/data.geojson"}}}, "test").result
|
||||
const themeConfig = new LayoutConfig(themeConfigJsonPrepared);
|
||||
const layerUnderTest = <LayerConfig> themeConfig.layers.find(l => l.id === "public_bookcase")
|
||||
expect(layerUnderTest.source.geojsonSource).eq("https://example.com/data.geojson")
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in a new issue