Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for theme.blue.100 token in design tokens build output #456

Merged
merged 1 commit into from
Aug 19, 2024
Merged
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
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}`
);
}
});
Loading