Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions src/__tests__/compiler/compiler.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,47 @@ test("animations preserve named keyframes and their timing contract", () => {
]);
});

test("breaks apart comma separated variables", () => {
const compiled = compile(
`
:root {
--test: blue, green;
}
`,
{
inlineVariables: false,
},
);
// css-variables-1 §2.1: a custom property's value is its tokens, its commas among them
test.each([
["blue, green", [["blue"], ["green"]]],
["blue ,green", [["blue"], ["green"]]],
["blue/**/, green", [["blue"], ["green"]]],
["blue green", ["blue", "green"]],
[
"1px 2px #000, 3px 4px #fff",
[
[1, 2, "#000"],
[3, 4, "#fff"],
],
],
["1px 2px #000 3px 4px #fff", [1, 2, "#000", 3, 4, "#fff"]],
])("--test: %s keeps its separator", (value, expected) => {
const compiled = compile(`:root { --test: ${value}; }`, {
inlineVariables: false,
});

expect(compiled.stylesheet()).toStrictEqual({
vr: [["test", [[["blue", "green"]]]]],
vr: [["test", [[expected]]]],
});
});

test.each([
["var(--a), var(--b)", [[[{}, "var", "a", 1]], [[{}, "var", "b", 1]]]],
[
"var(--a) var(--b)",
[
[{}, "var", "a", 1],
[{}, "var", "b", 1],
],
],
])("box-shadow: %s keeps its separator", (value, expected) => {
const compiled = compile(`.my-class { box-shadow: ${value}; }`);

expect(compiled.stylesheet().s?.[0]?.[1][0]?.d).toStrictEqual([
[[{}, "boxShadow", expected, 1], "boxShadow", 1],
]);
});

test("light-dark()", () => {
const compiled = compile(`
.my-class {
Expand Down
14 changes: 14 additions & 0 deletions src/__tests__/compiler/property.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,17 @@ test("an @property under an @supports that fails is not registered", () => {

expect(result.vp).toBeUndefined();
});

test("@property with a comma-separated repeated value keeps each item apart", () => {
const compiled = compile(`
@property --my-offsets {
syntax: "<length>#";
inherits: false;
initial-value: 10px, 20px;
}
`);

expect(compiled.stylesheet().vp).toStrictEqual([
["my-offsets", false, [[10], [20]]],
]);
});
Loading
Loading