Skip to content

Commit

Permalink
test: adds tests for nested tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
saneef committed Apr 15, 2024
1 parent 816e450 commit b6f0fd9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/custom-properties.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,31 @@ test("Generates properties from a group", async (t) => {
res.css,
":root{--font-family-base:sans-serif;--font-family-mono:monospace}",
);
});

test("Generates custom properties from nested tokens", async (t) => {
const tokens = {
color: {
gray: { 100: "#f1f5f9", 800: "#1e293b" },
},
};
const input = `:root { @design-token-utils (custom-properties); }`;
const res = await run(tokens, input, {
customProperties: [{ id: "color.gray", prefix: "shade" }],
});
t.is(res.css, ":root{--shade-100:#f1f5f9;--shade-800:#1e293b}");
});

test("Generates custom properties by group from nested tokens", async (t) => {
const tokens = {
color: {
gray: { 100: "#f1f5f9", 800: "#1e293b" },
primary: { 100: "#dcfce7", 800: "#166534" },
},
};
const input = `:root { @design-token-utils (custom-properties: shades); }`;
const res = await run(tokens, input, {
customProperties: [{ id: "color.gray", group: "shades" }],
});
t.is(res.css, ":root{--color-gray-100:#f1f5f9;--color-gray-800:#1e293b}");
});

0 comments on commit b6f0fd9

Please sign in to comment.