Skip to content

Commit 2a35e9e

Browse files
committed
chore: add tests to check the theme config
1 parent cce2bf3 commit 2a35e9e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

packages/tailwindcss-animations/test/index.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { describe, test, expect } from "vitest"
22
import { extractClasses } from "@halvaradop/tailwindcss-core/utils"
3-
import plugin from "../src/index.js"
3+
import { plugin } from "../src/index.js"
44
import { toSlashCase } from "../src/utils.js"
5+
import { theme } from "../src/theme.js"
56

67
export const generateClasses = extractClasses(plugin)
78

@@ -11,9 +12,15 @@ describe("Plugin", () => {
1112
const html = `<div class="animation-delay-100"></div>`
1213
const css = await generateClasses(html)
1314
expect(css).toMatch(".animation-delay-100{animation-delay:100ms}")
15+
expect(css).not.toMatch(".animation-delay-200{animation-delay:200ms}")
1416
})
1517
})
1618

19+
test("Loaded keyframes utility classes", async () => {
20+
expect(plugin.config?.theme?.keyframes).toEqual(theme.keyframes)
21+
expect(plugin.config?.theme?.keyframes).not.toEqual({})
22+
})
23+
1724
describe("Conflict prevention", () => {
1825
test.concurrent("should not create conflicting classes", async () => {
1926
const html = `<div class="w-full px-2 flex items-center"></div>`
@@ -56,6 +63,31 @@ describe("Animate delay utility classes", () => {
5663
})
5764
})
5865

66+
describe("Keyframes utility classes", () => {
67+
const testCases = [
68+
{
69+
className: "animate-fade-in",
70+
expected: "@keyframes fade-in{0%{opacity:0}100%{opacity:1}}",
71+
},
72+
{
73+
className: "animate-fade-out",
74+
expected: "@keyframes fade-out{0%{opacity:1}100%{opacity:0}}",
75+
},
76+
{
77+
className: "animate-rotate-90",
78+
expected: "@keyframes rotate-90{0%{transform:rotate(0deg)}100%{transform:rotate(90deg)}}",
79+
},
80+
]
81+
82+
testCases.forEach(({ className, expected }) => {
83+
test.concurrent(`keyframes with class ${className}`, async () => {
84+
const html = `<div class="${className}"></div>`
85+
const css = await generateClasses(html)
86+
expect(css).toMatch(expected)
87+
})
88+
})
89+
})
90+
5991
describe("toSlashCase", () => {
6092
const testCases = [
6193
{ input: "animation", expected: "animation" },

0 commit comments

Comments
 (0)