Skip to content

Commit aecc5ea

Browse files
author
requestmethod
committed
add utils test
1 parent 355c8d5 commit aecc5ea

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/utils_test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { assertEquals } from "https://deno.land/std/assert/mod.ts";
2+
3+
import {
4+
getRgbThemeConfig,
5+
getTailwindCssVariables,
6+
getThemeTokens,
7+
} from "./utils.ts";
8+
9+
Deno.test("getThemeTokens: returns array of tokens", () => {
10+
const tokens = getThemeTokens({
11+
dark: {
12+
"background-primary": "#000000",
13+
"text-primary": "#ffffff",
14+
},
15+
});
16+
17+
assertEquals(tokens, ["background-primary", "text-primary"]);
18+
});
19+
20+
Deno.test(
21+
"getTailwindCssVariables: converts rgba theme to tailwind css variable theme",
22+
() => {
23+
const theme: {
24+
[key: string]: {
25+
[key: string]: string;
26+
};
27+
} = {
28+
dark: {
29+
"background-primary": "#000000",
30+
"text-primary": "#ffffff",
31+
},
32+
};
33+
const prefix = "test-theme--";
34+
35+
const rgbTheme = getRgbThemeConfig(theme, prefix);
36+
37+
assertEquals(rgbTheme, {
38+
".test-theme--dark": {
39+
"--background-primary": "0 0 0",
40+
"--text-primary": "255 255 255",
41+
},
42+
});
43+
}
44+
);
45+
46+
Deno.test(
47+
"getTailwindCssVariables: returns prefixed, css variable theme with rgb color values",
48+
() => {
49+
const tokens = ["background-primary", "text-primary"];
50+
51+
const cssVariableTokens = getTailwindCssVariables(tokens);
52+
53+
assertEquals(cssVariableTokens, {
54+
"background-primary": `rgb(var(--background-primary) / <alpha-value>)`,
55+
"text-primary": `rgb(var(--text-primary) / <alpha-value>)`,
56+
});
57+
}
58+
);

0 commit comments

Comments
 (0)