11import { describe , test , expect } from "vitest"
22import { extractClasses } from "@halvaradop/tailwindcss-core/utils"
3- import plugin from "../src/index.js"
4- import { toSlashCase } from "../src/utils .js"
3+ import { plugin } from "../src/index.js"
4+ import { theme } from "../src/theme .js"
55
66export const generateClasses = extractClasses ( plugin )
77
@@ -11,9 +11,15 @@ describe("Plugin", () => {
1111 const html = `<div class="animation-delay-100"></div>`
1212 const css = await generateClasses ( html )
1313 expect ( css ) . toMatch ( ".animation-delay-100{animation-delay:100ms}" )
14+ expect ( css ) . not . toMatch ( ".animation-delay-200{animation-delay:200ms}" )
1415 } )
1516 } )
1617
18+ test ( "Loaded keyframes utility classes" , async ( ) => {
19+ expect ( plugin . config ?. theme ?. keyframes ) . toEqual ( theme . keyframes )
20+ expect ( plugin . config ?. theme ?. keyframes ) . not . toEqual ( { } )
21+ } )
22+
1723 describe ( "Conflict prevention" , ( ) => {
1824 test . concurrent ( "should not create conflicting classes" , async ( ) => {
1925 const html = `<div class="w-full px-2 flex items-center"></div>`
@@ -56,17 +62,27 @@ describe("Animate delay utility classes", () => {
5662 } )
5763} )
5864
59- describe ( "toSlashCase " , ( ) => {
65+ describe ( "Keyframes utility classes " , ( ) => {
6066 const testCases = [
61- { input : "animation" , expected : "animation" } ,
62- { input : "animationDelay" , expected : "animation-delay" } ,
63- { input : "animationDuration" , expected : "animation-duration" } ,
64- { input : "animationIterationCount" , expected : "animation-iteration-count" } ,
67+ {
68+ className : "animate-fade-in" ,
69+ expected : "@keyframes fade-in{0%{opacity:0}100%{opacity:1}}" ,
70+ } ,
71+ {
72+ className : "animate-fade-out" ,
73+ expected : "@keyframes fade-out{0%{opacity:1}100%{opacity:0}}" ,
74+ } ,
75+ {
76+ className : "animate-rotate-90" ,
77+ expected : "@keyframes rotate-90{0%{transform:rotate(0deg)}100%{transform:rotate(90deg)}}" ,
78+ } ,
6579 ]
6680
67- testCases . forEach ( ( { input, expected } ) => {
68- test ( `converts ${ input } to ${ expected } ` , ( ) => {
69- expect ( toSlashCase ( input ) ) . toBe ( expected )
81+ testCases . forEach ( ( { className, expected } ) => {
82+ test . concurrent ( `keyframes with class ${ className } ` , async ( ) => {
83+ const html = `<div class="${ className } "></div>`
84+ const css = await generateClasses ( html )
85+ expect ( css ) . toMatch ( expected )
7086 } )
7187 } )
7288} )
0 commit comments