Files
cunningham/packages/tokens/src/bin/Generators/CssGenerator.spec.ts
Nathan Vasse b908136224 (tokens) generate css utility classes
These were the missing parts in order to use every design tokens
of Cunningham. Including: spacing, font weight, size, family, and
colors. In order to be really versatile and to allow users to
define new design tokens I had to re-organize the way those tokens
are sub divided in sub objects in cunningham.ts file. That's why
sub division are created for theme.typ.sizes for instance.
2023-01-20 17:00:31 +01:00

49 lines
1.2 KiB
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("CssGenerator", () => {
beforeAll(() => {
jest.spyOn(console, "log").mockImplementation(() => {});
cleanup(__dirname);
});
afterEach(() => {
cleanup(__dirname);
});
const testSelector = async (opt: string) => {
const cssTokensFile = path.join(__dirname, Config.tokenFilename + ".css");
expect(fs.existsSync(cssTokensFile)).toEqual(false);
await run(["", "", "-g", "css", opt, "html"]);
expect(fs.existsSync(cssTokensFile)).toEqual(true);
expect(fs.readFileSync(cssTokensFile).toString()).toEqual(
fs
.readFileSync(
path.join(
__dirname,
"..",
"tests",
"assets",
"expected-default-" + Config.tokenFilename + ".css"
)
)
.toString()
.replace(":root", "html")
);
};
it("Runs with -s options.", async () => {
await testSelector("-s");
});
it("Runs with --selector options.", async () => {
await testSelector("--selector");
});
});