layer-without-tailwind.test.js 1.6 KB

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