Skip to content

Commit e2dd2bf

Browse files
test(css): drive the steps() count guard in-process
The config cases prove the behaviour but cannot report it: the minifier runs where the coverage run does not count it, so the whole math-fold region reads as unexecuted under the integration flag. `codecov/patch` is scoped to `unit` and `integration`, which is why the patch stayed at 46.66% while the comment, counting `syntax-equivalence` too, read 100%. These drive the same assertions through `SourceProcessor` directly, which runs in-process: every line and branch of the guard, each `<step-position>` the generated table names, the omitted position, a spelling it cannot read, a substitution standing where the keyword goes, and a comment between the arguments.
1 parent fad141f commit e2dd2bf

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎test/unitCases/CssSyntax.unittest.js‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6888,6 +6888,48 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
68886888
expect(minify("a{width:calc(5px - 5px)}")).toBe("a{width:0}");
68896889
});
68906890

6891+
it("keeps them on a `steps()` count its position would reject", () => {
6892+
// CSS Easing 2 puts the minimum at two under `jump-none` and one under
6893+
// every other position, and the bare literal is rejected where the
6894+
// `calc()` around the same value is clamped instead.
6895+
expect(value("steps(calc(1),jump-none)")).toBe("steps(calc(1),jump-none)");
6896+
expect(value("steps(calc(2),jump-none)")).toBe("steps(2,jump-none)");
6897+
expect(value("steps(calc(1),jump-both)")).toBe("steps(1,jump-both)");
6898+
// An omitted position is `end`, which takes one.
6899+
expect(value("steps(calc(1))")).toBe("steps(1)");
6900+
// Both names are read case-insensitively, so the guard still reads the
6901+
// position a source spelled in capitals.
6902+
expect(value("STEPS(calc(1),JUMP-NONE)")).toBe("steps(calc(1),JUMP-NONE)");
6903+
});
6904+
6905+
it("reads a `steps()` position it cannot name as the largest", () => {
6906+
// An unknown spelling, and a substitution standing where the keyword
6907+
// goes, could both resolve to `jump-none`, so the fold declines below
6908+
// two rather than guess.
6909+
expect(value("steps(calc(1),jump-sideways)")).toBe(
6910+
"steps(calc(1),jump-sideways)"
6911+
);
6912+
expect(value("steps(calc(2),jump-sideways)")).toBe(
6913+
"steps(2,jump-sideways)"
6914+
);
6915+
expect(value("steps(calc(1),var(--pos))")).toBe(
6916+
"steps(calc(1),var(--pos))"
6917+
);
6918+
// A comment between the arguments is not the position.
6919+
expect(value("steps(calc(1),/*c*/jump-none)")).toBe(
6920+
"steps(calc(1),jump-none)"
6921+
);
6922+
});
6923+
6924+
it("drives every `<step-position>` the table names", () => {
6925+
// `steps(1, …)` has a keyword of its own at each end, which is what the
6926+
// positions taking one count print as.
6927+
expect(value("steps(calc(1),jump-start)")).toBe("step-start");
6928+
expect(value("steps(calc(1),start)")).toBe("step-start");
6929+
expect(value("steps(calc(1),jump-end)")).toBe("step-end");
6930+
expect(value("steps(calc(1),end)")).toBe("step-end");
6931+
});
6932+
68916933
it("does not run inside a `@supports` condition or a custom property", () => {
68926934
const supports = "@supports (width:calc(1px + 2px)){a{color:red}}";
68936935
expect(minify(supports)).toBe(supports);

0 commit comments

Comments
 (0)