mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* move `./tests/jit` to `./tests` * make tests consistent Abstracted a `run` function and some syntax highlighting helpers for `html`, `css` and `javascript`.
82 lines
1.6 KiB
JavaScript
82 lines
1.6 KiB
JavaScript
import path from 'path'
|
|
|
|
import { run, css } from './util/run'
|
|
|
|
test('using @layer without @tailwind', async () => {
|
|
let config = {
|
|
content: [path.resolve(__dirname, './layer-without-tailwind.test.html')],
|
|
}
|
|
|
|
let input = css`
|
|
@layer components {
|
|
.foo {
|
|
color: black;
|
|
}
|
|
}
|
|
`
|
|
|
|
await expect(run(input, config)).rejects.toThrowError(
|
|
'`@layer components` is used but no matching `@tailwind components` directive is present.'
|
|
)
|
|
})
|
|
|
|
test('using @responsive without @tailwind', async () => {
|
|
let config = {
|
|
content: [path.resolve(__dirname, './layer-without-tailwind.test.html')],
|
|
}
|
|
|
|
let input = css`
|
|
@responsive {
|
|
.foo {
|
|
color: black;
|
|
}
|
|
}
|
|
`
|
|
|
|
await expect(run(input, config)).rejects.toThrowError(
|
|
'`@responsive` is used but `@tailwind utilities` is missing.'
|
|
)
|
|
})
|
|
|
|
test('using @variants without @tailwind', async () => {
|
|
let config = {
|
|
content: [path.resolve(__dirname, './layer-without-tailwind.test.html')],
|
|
}
|
|
|
|
let input = css`
|
|
@variants hover {
|
|
.foo {
|
|
color: black;
|
|
}
|
|
}
|
|
`
|
|
|
|
await expect(run(input, config)).rejects.toThrowError(
|
|
'`@variants` is used but `@tailwind utilities` is missing.'
|
|
)
|
|
})
|
|
|
|
test('non-Tailwind @layer rules are okay', async () => {
|
|
let config = {
|
|
content: [path.resolve(__dirname, './layer-without-tailwind.test.html')],
|
|
}
|
|
|
|
let input = css`
|
|
@layer custom {
|
|
.foo {
|
|
color: black;
|
|
}
|
|
}
|
|
`
|
|
|
|
return run(input, config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
@layer custom {
|
|
.foo {
|
|
color: black;
|
|
}
|
|
}
|
|
`)
|
|
})
|
|
})
|