✨(tokens) add JS generator and re-organize the repo
Added JsGenerator which to implied to reorganize a bit the repo in order to extract generator-specific test into specific standalone files.
This commit is contained in:
30
packages/tokens/src/bin/Generators/JsGenerator.spec.ts
Normal file
30
packages/tokens/src/bin/Generators/JsGenerator.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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.tokenFilenames.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"}};`
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user