Increase coverage to about 80%

This commit is contained in:
HarelM
2026-07-10 21:11:41 +03:00
parent 70a2db580f
commit d039dc73a5
21 changed files with 765 additions and 221 deletions
+84 -2
View File
@@ -76,6 +76,16 @@ describe("layer editor", () => {
layers: [{ id: "background:" + bgId, type: "background", minzoom: 1 }],
});
});
test("the range slider adjusts min-zoom", async () => {
await when.focus("min-zoom.input-range");
await when.typeKeys("{rightarrow}");
await then(
get
.styleFromLocalStorage()
.then((style) => typeof style.layers.find((l: any) => l.id === "background:" + bgId).minzoom)
).shouldEqual("number");
});
});
describe("max-zoom", () => {
@@ -145,6 +155,15 @@ describe("layer editor", () => {
layers: [{ id: "background:" + bgId, type: "background" }],
});
});
test("typing a hex value updates the paint color", async () => {
await when.setColorValue("background-color", "#ff0000");
await then(
get
.styleFromLocalStorage()
.then((style) => style.layers.find((l: any) => l.id === "background:" + bgId).paint["background-color"])
).shouldEqual("#ff0000");
});
});
describe("opacity", () => {
@@ -166,8 +185,71 @@ describe("layer editor", () => {
});
describe("filter", () => {
test.skip("expand/collapse", () => {});
test.skip("compound filter", () => {});
test("compound filter", async () => {
const id = await when.modal.fillLayers({ type: "fill", layer: "example" });
await when.addFilter();
await then(
get.styleFromLocalStorage().then((style) => style.layers.find((l: any) => l.id === id).filter)
).shouldDeepNestedInclude(["all", ["==", "name", ""]]);
// Changing the operator updates the compound filter.
await when.selectFilterOperator("!=");
await then(
get.styleFromLocalStorage().then((style) => style.layers.find((l: any) => l.id === id).filter)
).shouldDeepNestedInclude(["all", ["!=", "name", ""]]);
// A second filter item extends the compound filter.
await when.addFilter();
await then(
get.styleFromLocalStorage().then((style) => style.layers.find((l: any) => l.id === id).filter)
).shouldDeepNestedInclude(["all", ["!=", "name", ""], ["==", "name", ""]]);
});
});
describe("functions", () => {
test("convert a property to a zoom function and add a stop", async () => {
const id = await when.modal.fillLayers({ type: "circle", layer: "example" });
await when.makeZoomFunction("circle-radius");
await then(
get.styleFromLocalStorage().then((style) => style.layers.find((l: any) => l.id === id).paint)
).shouldDeepNestedInclude({ "circle-radius": { stops: [[6, 5], [10, 5]] } });
await when.addFunctionStop("circle-radius");
await then(
get.styleFromLocalStorage().then((style) => style.layers.find((l: any) => l.id === id).paint)
).shouldDeepNestedInclude({ "circle-radius": { stops: [[6, 5], [10, 5], [11, 5]] } });
await when.deleteFunctionStop("circle-radius");
await then(
get
.styleFromLocalStorage()
.then((style) => style.layers.find((l: any) => l.id === id).paint["circle-radius"].stops.length)
).shouldEqual(2);
});
test("convert a property to a data function and edit stops", async () => {
const id = await when.modal.fillLayers({ type: "circle", layer: "example" });
// The property needs a value before it can be turned into a data function.
await when.setValue("spec-field-input:circle-blur", "1");
await when.makeDataFunction("circle-blur");
await then(
get.styleFromLocalStorage().then((style) => style.layers.find((l: any) => l.id === id).paint["circle-blur"].type)
).shouldEqual("exponential");
await when.addFunctionStop("circle-blur");
await then(
get
.styleFromLocalStorage()
.then((style) => style.layers.find((l: any) => l.id === id).paint["circle-blur"].stops.length)
).shouldEqual(3);
await when.deleteFunctionStop("circle-blur");
await then(
get
.styleFromLocalStorage()
.then((style) => style.layers.find((l: any) => l.id === id).paint["circle-blur"].stops.length)
).shouldEqual(2);
});
});
describe("layout", () => {