mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* Run test suite against both engines * make eslint happy * only run `stable` tests on Node 12 * use normal expectation instead of snapshot file When we run the tests only against `stable` (for node 12), then the snapshots exists for the `Oxide` build. They are marked as `obsolete` and will cause the `npm run test` script to fail. Sadly. Inlined them for now, but ideally we make those tests more blackbox-y so that we test that we get source maps and that we can map the sourcemap back to the input files (without looking at the actual annotations). * properly indent inline css Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com> Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import { generateRules } from '../src/lib/generateRules'
|
|
import resolveConfig from '../src/public/resolve-config'
|
|
import { createContext } from '../src/lib/setupContextUtils'
|
|
import { crosscheck, css } from './util/run'
|
|
|
|
crosscheck(() => {
|
|
it('should not generate rules that are incorrect', () => {
|
|
let config = {
|
|
plugins: [
|
|
({ matchVariant }) => {
|
|
matchVariant('@', (value) => `@container (min-width: ${value})`)
|
|
},
|
|
],
|
|
}
|
|
let context = createContext(resolveConfig(config))
|
|
let rules = generateRules(
|
|
new Set([
|
|
// Invalid, missing `-`
|
|
'group[:hover]:underline',
|
|
|
|
// Invalid, `-` should not be there
|
|
'@-[200px]:underline',
|
|
|
|
// Valid
|
|
'group-[:hover]:underline',
|
|
'@[200px]:underline',
|
|
]),
|
|
context
|
|
)
|
|
|
|
// Ensure we only have 2 valid rules
|
|
expect(rules).toHaveLength(2)
|
|
|
|
// Ensure we have the correct values
|
|
expect(rules[0][1].toString()).toMatchFormattedCss(css`
|
|
.group:hover .group-\[\:hover\]\:underline {
|
|
text-decoration-line: underline;
|
|
}
|
|
`)
|
|
expect(rules[1][1].toString()).toMatchFormattedCss(css`
|
|
@container (min-width: 200px) {
|
|
.\@\[200px\]\:underline {
|
|
text-decoration-line: underline;
|
|
}
|
|
}
|
|
`)
|
|
})
|
|
})
|