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!
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
import postcss from 'postcss'
|
|
import plugin from '../src/lib/substituteScreenAtRules'
|
|
import config from '../stubs/defaultConfig.stub.js'
|
|
import { crosscheck, css } from './util/run'
|
|
|
|
function run(input, opts = config) {
|
|
return postcss([plugin({ tailwindConfig: opts })]).process(input, { from: undefined })
|
|
}
|
|
|
|
crosscheck(() => {
|
|
test('it can generate media queries from configured screen sizes', () => {
|
|
let input = css`
|
|
@screen sm {
|
|
.banana {
|
|
color: yellow;
|
|
}
|
|
}
|
|
@screen md {
|
|
.banana {
|
|
color: red;
|
|
}
|
|
}
|
|
@screen lg {
|
|
.banana {
|
|
color: green;
|
|
}
|
|
}
|
|
`
|
|
|
|
return run(input, {
|
|
theme: {
|
|
screens: {
|
|
sm: '500px',
|
|
md: '750px',
|
|
lg: '1000px',
|
|
},
|
|
},
|
|
separator: ':',
|
|
}).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@media (min-width: 500px) {
|
|
.banana {
|
|
color: #ff0;
|
|
}
|
|
}
|
|
@media (min-width: 750px) {
|
|
.banana {
|
|
color: red;
|
|
}
|
|
}
|
|
@media (min-width: 1000px) {
|
|
.banana {
|
|
color: green;
|
|
}
|
|
}
|
|
`)
|
|
expect(result.warnings().length).toBe(0)
|
|
})
|
|
})
|
|
})
|