Skip to content

Commit

Permalink
Add test for theme.blue.100 token in build output
Browse files Browse the repository at this point in the history
  • Loading branch information
ty2k committed Aug 19, 2024
1 parent 8e58de3 commit ef243bc
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion packages/design-tokens/build-output.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from "child_process";
import { existsSync } from "fs";
import { existsSync, readFileSync } from "fs";
import { test } from "node:test";
import assert from "node:assert";
import { join } from "path";
Expand Down Expand Up @@ -47,3 +47,57 @@ test("output files should exist after running build-output.js", async () => {
assert.ok(existsSync(filePath), `Expected file ${file} to exist`);
}
});

test("theme.blue.100 should be present in all output files", async () => {
const checks = [
{
file: "build/css/variables.css",
token: "--theme-blue-100: #013366;",
},
{
file: "build/css-prefixed/variables.css",
token: "--bcds-theme-blue-100: #013366;",
},
{
file: "build/js/index.js",
token: 'export const themeBlue100 = "#013366";',
},
{
file: "build/js/index.d.ts",
token: "export const themeBlue100 : string;",
},
{
file: "build/js-prefixed/index.js",
token: 'export const bcdsThemeBlue100 = "#013366";',
},
{
file: "build/js-prefixed/index.d.ts",
token: "export const bcdsThemeBlue100 : string;",
},
{
file: "build/cjs/index.js",
token: '"themeBlue100": "#013366"',
},
{
file: "build/cjs/index.d.ts",
token: "export const themeBlue100 : string;",
},
{
file: "build/cjs-prefixed/index.js",
token: '"bcdsThemeBlue100": "#013366"',
},
{
file: "build/cjs-prefixed/index.d.ts",
token: "export const bcdsThemeBlue100 : string;",
},
];

for (const { file, token } of checks) {
const filePath = join(process.cwd(), file);
const fileContent = readFileSync(filePath, "utf-8");
assert.ok(
fileContent.includes(token),
`Expected token "${token}" to be present in file ${file}`
);
}
});

0 comments on commit ef243bc

Please sign in to comment.