warnings.test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { run, html, css } from './util/run'
  2. test('it warns when there is no content key', async () => {
  3. let config = {
  4. presets: [], // Prevents the default config from being merged in and therefore `content: ['auto']` is not used.
  5. corePlugins: { preflight: false },
  6. }
  7. let input = css`
  8. @tailwind base;
  9. `
  10. await run(input, config)
  11. expect().toHaveBeenWarnedWith(['content-problems'])
  12. })
  13. test('it warns when there is an empty content key', async () => {
  14. let config = {
  15. content: [],
  16. corePlugins: { preflight: false },
  17. }
  18. let input = css`
  19. @tailwind base;
  20. `
  21. await run(input, config)
  22. expect().toHaveBeenWarnedWith(['content-problems'])
  23. })
  24. test('it warns when there are no utilities generated', async () => {
  25. let config = {
  26. content: [{ raw: html`nothing here matching a utility` }],
  27. corePlugins: { preflight: false },
  28. }
  29. let input = css`
  30. @tailwind utilities;
  31. `
  32. await run(input, config)
  33. expect().toHaveBeenWarnedWith(['content-problems'])
  34. })
  35. it('warnings are not thrown when only variant utilities are generated', async () => {
  36. let config = {
  37. content: [{ raw: html`<div class="sm:underline"></div>` }],
  38. corePlugins: { preflight: false },
  39. }
  40. let input = css`
  41. @tailwind utilities;
  42. `
  43. await run(input, config)
  44. expect().not.toHaveBeenWarned()
  45. })