Skip to content

Commit e9af285

Browse files
committed
feat(tailwind): test non-inlinable custom utilities (#2586)
1 parent 1b58d59 commit e9af285

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ exports[`Tailwind component > with non-inlinable styles > adds css to <head/> an
140140
"
141141
`;
142142
143+
exports[`Tailwind component > with non-inlinable styles > handles non-inlinable styles in custom utilities 1`] = `
144+
"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
145+
<html lang="en">
146+
<head>
147+
<!--$-->
148+
<style>
149+
.text-body{color:green!important;@media (width>=40rem){color:darkgreen!important}}
150+
</style>
151+
</head>
152+
<body>
153+
<div class="text-body"></div>
154+
<!--/$-->
155+
</body>
156+
</html>
157+
"
158+
`;
159+
143160
exports[`Tailwind component > with non-inlinable styles > persists existing <head/> elements 1`] = `
144161
"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
145162
<html lang="en">

packages/tailwind/src/tailwind.spec.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,34 @@ describe('Tailwind component', () => {
378378
).toMatchSnapshot();
379379
});
380380

381+
it('handles non-inlinable styles in custom utilities', async () => {
382+
const actualOutput = await render(
383+
<html lang="en">
384+
<Tailwind
385+
config={{
386+
plugins: [
387+
{
388+
handler: (api) => {
389+
api.addUtilities({
390+
'.text-body': {
391+
'@apply text-[green] sm:text-[darkgreen]': {},
392+
},
393+
});
394+
},
395+
},
396+
],
397+
}}
398+
>
399+
<head />
400+
<body>
401+
<div className="text-body" />
402+
</body>
403+
</Tailwind>
404+
</html>,
405+
).then(pretty);
406+
expect(actualOutput).toMatchSnapshot();
407+
});
408+
381409
it('adds css to <head/> and keep class names', async () => {
382410
const actualOutput = await render(
383411
<html lang="en">

0 commit comments

Comments
 (0)