1
1
import { describe , test , expect } from "vitest"
2
2
import { extractClasses } from "@halvaradop/tailwindcss-core/utils"
3
- import plugin from "../src/index.js"
3
+ import { plugin } from "../src/index.js"
4
4
import { toSlashCase } from "../src/utils.js"
5
+ import { theme } from "../src/theme.js"
5
6
6
7
export const generateClasses = extractClasses ( plugin )
7
8
@@ -11,9 +12,15 @@ describe("Plugin", () => {
11
12
const html = `<div class="animation-delay-100"></div>`
12
13
const css = await generateClasses ( html )
13
14
expect ( css ) . toMatch ( ".animation-delay-100{animation-delay:100ms}" )
15
+ expect ( css ) . not . toMatch ( ".animation-delay-200{animation-delay:200ms}" )
14
16
} )
15
17
} )
16
18
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
+
17
24
describe ( "Conflict prevention" , ( ) => {
18
25
test . concurrent ( "should not create conflicting classes" , async ( ) => {
19
26
const html = `<div class="w-full px-2 flex items-center"></div>`
@@ -56,6 +63,31 @@ describe("Animate delay utility classes", () => {
56
63
} )
57
64
} )
58
65
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
+
59
91
describe ( "toSlashCase" , ( ) => {
60
92
const testCases = [
61
93
{ input : "animation" , expected : "animation" } ,
0 commit comments