Files
cunningham/packages/tokens/src/bin/Generators/JsGenerator.spec.ts
Nathan Vasse 66e6aad84d (tokens) add TS generator and re-organize the repo
Add TS Generator which is a lot based on JS Generator.
2023-01-11 11:01:56 +01:00

31 lines
843 B
TypeScript

import path from "path";
import fs from "fs";
import Config from "Config";
import { run } from "ThemeGenerator";
import { cleanup } from "tests/Utils";
jest.mock("../Paths", () => ({
workPath: () => __dirname,
}));
describe("JsGenerator", () => {
beforeAll(() => {
jest.spyOn(console, "log").mockImplementation(() => {});
cleanup(__dirname);
});
afterEach(() => {
cleanup(__dirname);
});
it("generates valid JS file.", async () => {
const tokensFile = path.join(__dirname, Config.tokenFilename + ".js");
expect(fs.existsSync(tokensFile)).toEqual(false);
await run(["", "", "-g", "js"]);
expect(fs.existsSync(tokensFile)).toEqual(true);
expect(fs.readFileSync(tokensFile).toString()).toEqual(
`export const tokens = {"colors":{"primary":"#055FD2","secondary":"#DA0000"}};`
);
});
});