mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* drop empty lines when diffing output * replace expected css with optimized lightningcss output Lightning CSS generates a more optimal CSS output. Right now the tests are setup in a way that both the generated css and expected css are run through `lightningcss` to make sure that the output is concistent for the `stable` and `oxide` engines. But this also means that the expected output _could_ be larger (aka not optimized) and still matches (after it runs through lightningcss). By replacing this with the more optimal output we achieve a few things: 1. This better reflects reality since we will be using `lightningcss`. 2. This gets rid of unnecessary css. 3. Removed code!
158 lines
3.9 KiB
JavaScript
158 lines
3.9 KiB
JavaScript
import { crosscheck, run, html, css } from './util/run'
|
|
|
|
crosscheck(() => {
|
|
test('responsive and variants atrules', () => {
|
|
let config = {
|
|
content: [
|
|
{
|
|
raw: html`
|
|
<div class="responsive-in-utilities"></div>
|
|
<div class="variants-in-utilities"></div>
|
|
<div class="both-in-utilities"></div>
|
|
<div class="responsive-at-root"></div>
|
|
<div class="variants-at-root"></div>
|
|
<div class="both-at-root"></div>
|
|
<div class="responsive-in-components"></div>
|
|
<div class="variants-in-components"></div>
|
|
<div class="both-in-components"></div>
|
|
<div class="md:focus:responsive-in-utilities"></div>
|
|
<div class="md:focus:variants-in-utilities"></div>
|
|
<div class="md:focus:both-in-utilities"></div>
|
|
<div class="md:focus:responsive-at-root"></div>
|
|
<div class="md:focus:variants-at-root"></div>
|
|
<div class="md:focus:both-at-root"></div>
|
|
<div class="md:focus:responsive-in-components"></div>
|
|
<div class="md:focus:variants-in-components"></div>
|
|
<div class="md:focus:both-in-components"></div>
|
|
`,
|
|
},
|
|
],
|
|
corePlugins: { preflight: false },
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind components;
|
|
@tailwind utilities;
|
|
|
|
@layer utilities {
|
|
@responsive {
|
|
.responsive-in-utilities {
|
|
color: blue;
|
|
}
|
|
}
|
|
@variants {
|
|
.variants-in-utilities {
|
|
color: red;
|
|
}
|
|
}
|
|
@responsive {
|
|
@variants {
|
|
.both-in-utilities {
|
|
color: green;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@responsive {
|
|
.responsive-at-root {
|
|
color: white;
|
|
}
|
|
}
|
|
@variants {
|
|
.variants-at-root {
|
|
color: orange;
|
|
}
|
|
}
|
|
@responsive {
|
|
@variants {
|
|
.both-at-root {
|
|
color: pink;
|
|
}
|
|
}
|
|
}
|
|
|
|
@layer components {
|
|
@responsive {
|
|
.responsive-in-components {
|
|
color: blue;
|
|
}
|
|
}
|
|
@variants {
|
|
.variants-in-components {
|
|
color: red;
|
|
}
|
|
}
|
|
@responsive {
|
|
@variants {
|
|
.both-in-components {
|
|
color: green;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
return run(input, config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
.responsive-in-components {
|
|
color: #00f;
|
|
}
|
|
.variants-in-components {
|
|
color: red;
|
|
}
|
|
.both-in-components {
|
|
color: green;
|
|
}
|
|
.responsive-in-utilities {
|
|
color: #00f;
|
|
}
|
|
.variants-in-utilities {
|
|
color: red;
|
|
}
|
|
.both-in-utilities {
|
|
color: green;
|
|
}
|
|
.responsive-at-root {
|
|
color: #fff;
|
|
}
|
|
.variants-at-root {
|
|
color: orange;
|
|
}
|
|
.both-at-root {
|
|
color: pink;
|
|
}
|
|
@media (min-width: 768px) {
|
|
.md\:focus\:responsive-in-components:focus {
|
|
color: #00f;
|
|
}
|
|
.md\:focus\:variants-in-components:focus {
|
|
color: red;
|
|
}
|
|
.md\:focus\:both-in-components:focus {
|
|
color: green;
|
|
}
|
|
.md\:focus\:responsive-in-utilities:focus {
|
|
color: #00f;
|
|
}
|
|
.md\:focus\:variants-in-utilities:focus {
|
|
color: red;
|
|
}
|
|
.md\:focus\:both-in-utilities:focus {
|
|
color: green;
|
|
}
|
|
.md\:focus\:responsive-at-root:focus {
|
|
color: #fff;
|
|
}
|
|
.md\:focus\:variants-at-root:focus {
|
|
color: orange;
|
|
}
|
|
.md\:focus\:both-at-root:focus {
|
|
color: pink;
|
|
}
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
})
|