tailwindcss/tests/layer-without-tailwind.test.js
Robin Malfait 1454190ea0
inline tests (#10362)
This will reduce the amount of different test "implementations" and
should further unify/normalise the tests. Some tests are very large and
can be split up more but this is a start in the right direction.

One of the biggest benefits is that changes in the tests file re-trigger
a jest run in watch mode. A change in the HTML/CSS file won't.
2023-01-19 11:42:52 +01:00

80 lines
1.5 KiB
JavaScript

import { run, html, css } from './util/run'
test('using @layer without @tailwind', async () => {
let config = {
content: [{ raw: html`<div class="foo"></div>` }],
}
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: [{ raw: html`<div class="foo"></div>` }],
}
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: [{ raw: html`<div class="foo"></div>` }],
}
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: [{ raw: html`<div class="foo"></div>` }],
}
let input = css`
@layer custom {
.foo {
color: black;
}
}
`
return run(input, config).then((result) => {
expect(result.css).toMatchFormattedCss(css`
@layer custom {
.foo {
color: black;
}
}
`)
})
})