Skip to content

Commit 4e3e724

Browse files
committed
Add test for @variant inside addBase
1 parent babe825 commit 4e3e724

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

packages/tailwindcss/src/index.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,6 +4665,45 @@ test('addBase', async () => {
46654665
`)
46664666
})
46674667

4668+
test('JS APIs support @variant', async () => {
4669+
let { build } = await compile(
4670+
css`
4671+
@plugin "my-plugin";
4672+
@layer base, utilities;
4673+
@layer utilities {
4674+
@tailwind utilities;
4675+
}
4676+
`,
4677+
{
4678+
loadModule: async () => ({
4679+
path: '',
4680+
base: '/root',
4681+
module: ({ addBase }: PluginAPI) => {
4682+
addBase({ body: { '@variant dark': { color: 'red' } } })
4683+
},
4684+
}),
4685+
},
4686+
)
4687+
4688+
let compiled = build(['underline'])
4689+
4690+
expect(optimizeCss(compiled).trim()).toMatchInlineSnapshot(`
4691+
"@layer base {
4692+
@media (prefers-color-scheme: dark) {
4693+
body {
4694+
color: red;
4695+
}
4696+
}
4697+
}
4698+
4699+
@layer utilities {
4700+
.underline {
4701+
text-decoration-line: underline;
4702+
}
4703+
}"
4704+
`)
4705+
})
4706+
46684707
it("should error when `layer(…)` is used, but it's not the first param", async () => {
46694708
await expect(async () => {
46704709
return await compileCss(

0 commit comments

Comments
 (0)