import { describe, expect, it } from 'vitest' import { transformCssVars } from '../../../src/utils/updaters/update-css-vars' describe('transformCssVars', () => { it('should add light and dark css vars if not present', async () => { expect( await transformCssVars( `@tailwind base; @tailwind components; @tailwind utilities; `, { light: { background: 'white', foreground: 'black', }, dark: { background: 'black', foreground: 'white', }, }, { tailwind: { cssVariables: true, }, }, ), ).toMatchInlineSnapshot(` "@tailwind base; @tailwind components; @tailwind utilities; @layer base { :root { --background: white; --foreground: black } .dark { --background: black; --foreground: white } } @layer base { * { @apply border-border; } body { @apply bg-background text-foreground; } } " `) }) it('should update light and dark css vars if present', async () => { expect( await transformCssVars( `@tailwind base; @tailwind components; @tailwind utilities; @layer base{ :root{ --background: 210 40% 98%; } .dark{ --background: 222.2 84% 4.9%; } } `, { light: { background: '215 20.2% 65.1%', foreground: '222.2 84% 4.9%', }, dark: { foreground: '60 9.1% 97.8%', }, }, { tailwind: { cssVariables: true, }, }, ), ).toMatchInlineSnapshot(` "@tailwind base; @tailwind components; @tailwind utilities; @layer base{ :root{ --background: 215 20.2% 65.1%; --foreground: 222.2 84% 4.9%; } .dark{ --background: 222.2 84% 4.9%; --foreground: 60 9.1% 97.8%; } } @layer base { * { @apply border-border; } body { @apply bg-background text-foreground; } } " `) }) it('should not add the base layer if it is already present', async () => { expect( await transformCssVars( `@tailwind base; @tailwind components; @tailwind utilities; @layer base{ :root{ --background: 210 40% 98%; } .dark{ --background: 222.2 84% 4.9%; } } @layer base { * { @apply border-border; } body { @apply bg-background text-foreground; } } `, {}, { tailwind: { cssVariables: true, }, }, ), ).toMatchInlineSnapshot(` "@tailwind base; @tailwind components; @tailwind utilities; @layer base{ :root{ --background: 210 40% 98%; } .dark{ --background: 222.2 84% 4.9%; } } @layer base { * { @apply border-border; } body { @apply bg-background text-foreground; } } " `) }) })