tailwindcss/tests/layer-without-tailwind.test.js
Adam Wathan 42136e94ce
Run test suite against both engines (#10373)
* 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>
2023-01-20 18:45:04 +01:00

82 lines
1.7 KiB
JavaScript

import { crosscheck, run, html, css } from './util/run'
crosscheck(() => {
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;
}
}
`)
})
})
})