Skip to content

Commit db4968d

Browse files
committed
Test layer updates directly
1 parent 4dbb78c commit db4968d

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

tests/context-reuse.test.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
<title>Title</title>
88
<link rel="stylesheet" href="./tailwind.css" />
99
</head>
10-
<body></body>
10+
<body>
11+
<div class="only:custom-utility"></div>
12+
</body>
1113
</html>

tests/context-reuse.test.js

+40
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,46 @@ it('re-uses the context across multiple files with the same config', async () =>
8787
expect(sharedState.contextSourcesMap.size).toBe(1)
8888
})
8989

90+
it('updates layers when any CSS containing @tailwind directives changes', async () => {
91+
let result
92+
93+
// Compile the initial version once
94+
let input = css`
95+
@tailwind utilities;
96+
@layer utilities {
97+
.custom-utility {
98+
color: orange;
99+
}
100+
}
101+
`
102+
103+
result = await run(input, configPath, `id=1`)
104+
105+
expect(result.css).toMatchFormattedCss(css`
106+
.only\:custom-utility:only-child {
107+
color: orange;
108+
}
109+
`)
110+
111+
// Save the file with a change
112+
input = css`
113+
@tailwind utilities;
114+
@layer utilities {
115+
.custom-utility {
116+
color: blue;
117+
}
118+
}
119+
`
120+
121+
result = await run(input, configPath, `id=1`)
122+
123+
expect(result.css).toMatchFormattedCss(css`
124+
.only\:custom-utility:only-child {
125+
color: blue;
126+
}
127+
`)
128+
})
129+
90130
it('invalidates the context when any CSS containing @tailwind directives changes', async () => {
91131
sharedState.contextInvalidationCount = 0
92132
sharedState.sourceHashMap.clear()

0 commit comments

Comments
 (0)