Skip to content

Commit

Permalink
Test layer updates directly
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Feb 25, 2022
1 parent 4dbb78c commit db4968d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/context-reuse.test.html
Expand Up @@ -7,5 +7,7 @@
<title>Title</title>
<link rel="stylesheet" href="./tailwind.css" />
</head>
<body></body>
<body>
<div class="only:custom-utility"></div>
</body>
</html>
40 changes: 40 additions & 0 deletions tests/context-reuse.test.js
Expand Up @@ -87,6 +87,46 @@ it('re-uses the context across multiple files with the same config', async () =>
expect(sharedState.contextSourcesMap.size).toBe(1)
})

it('updates layers when any CSS containing @tailwind directives changes', async () => {
let result

// Compile the initial version once
let input = css`
@tailwind utilities;
@layer utilities {
.custom-utility {
color: orange;
}
}
`

result = await run(input, configPath, `id=1`)

expect(result.css).toMatchFormattedCss(css`
.only\:custom-utility:only-child {
color: orange;
}
`)

// Save the file with a change
input = css`
@tailwind utilities;
@layer utilities {
.custom-utility {
color: blue;
}
}
`

result = await run(input, configPath, `id=1`)

expect(result.css).toMatchFormattedCss(css`
.only\:custom-utility:only-child {
color: blue;
}
`)
})

it('invalidates the context when any CSS containing @tailwind directives changes', async () => {
sharedState.contextInvalidationCount = 0
sharedState.sourceHashMap.clear()
Expand Down

0 comments on commit db4968d

Please sign in to comment.