layer-without-tailwind.test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { run, html, css } from './util/run'
  2. test('using @layer without @tailwind', async () => {
  3. let config = {
  4. content: [{ raw: html`<div class="foo"></div>` }],
  5. }
  6. let input = css`
  7. @layer components {
  8. .foo {
  9. color: black;
  10. }
  11. }
  12. `
  13. await expect(run(input, config)).rejects.toThrowError(
  14. '`@layer components` is used but no matching `@tailwind components` directive is present.'
  15. )
  16. })
  17. test('using @responsive without @tailwind', async () => {
  18. let config = {
  19. content: [{ raw: html`<div class="foo"></div>` }],
  20. }
  21. let input = css`
  22. @responsive {
  23. .foo {
  24. color: black;
  25. }
  26. }
  27. `
  28. await expect(run(input, config)).rejects.toThrowError(
  29. '`@responsive` is used but `@tailwind utilities` is missing.'
  30. )
  31. })
  32. test('using @variants without @tailwind', async () => {
  33. let config = {
  34. content: [{ raw: html`<div class="foo"></div>` }],
  35. }
  36. let input = css`
  37. @variants hover {
  38. .foo {
  39. color: black;
  40. }
  41. }
  42. `
  43. await expect(run(input, config)).rejects.toThrowError(
  44. '`@variants` is used but `@tailwind utilities` is missing.'
  45. )
  46. })
  47. test('non-Tailwind @layer rules are okay', async () => {
  48. let config = {
  49. content: [{ raw: html`<div class="foo"></div>` }],
  50. }
  51. let input = css`
  52. @layer custom {
  53. .foo {
  54. color: black;
  55. }
  56. }
  57. `
  58. return run(input, config).then((result) => {
  59. expect(result.css).toMatchFormattedCss(css`
  60. @layer custom {
  61. .foo {
  62. color: #000;
  63. }
  64. }
  65. `)
  66. })
  67. })