From ef243bc10e14d107792d3bb98ad4b311c40071df Mon Sep 17 00:00:00 2001 From: Tyler Krys Date: Mon, 19 Aug 2024 14:05:01 -0700 Subject: [PATCH] Add test for theme.blue.100 token in build output --- packages/design-tokens/build-output.test.js | 56 ++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/design-tokens/build-output.test.js b/packages/design-tokens/build-output.test.js index d8884ef3..93cc7bf4 100644 --- a/packages/design-tokens/build-output.test.js +++ b/packages/design-tokens/build-output.test.js @@ -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"; @@ -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}` + ); + } +});