raw-content.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import fs from 'fs'
  2. import path from 'path'
  3. import { run, css } from './util/run'
  4. it('raw content', () => {
  5. let config = {
  6. content: [{ raw: fs.readFileSync(path.resolve(__dirname, './raw-content.test.html'), 'utf8') }],
  7. corePlugins: { preflight: false },
  8. }
  9. let input = css`
  10. @tailwind components;
  11. @tailwind utilities;
  12. `
  13. return run(input, config).then((result) => {
  14. let expectedPath = path.resolve(__dirname, './raw-content.test.css')
  15. let expected = fs.readFileSync(expectedPath, 'utf8')
  16. expect(result.css).toMatchFormattedCss(expected)
  17. })
  18. })
  19. test('raw content with extension', () => {
  20. let config = {
  21. content: {
  22. files: [
  23. {
  24. raw: fs.readFileSync(path.resolve(__dirname, './raw-content.test.html'), 'utf8'),
  25. extension: 'html',
  26. },
  27. ],
  28. extract: {
  29. html: () => ['invisible'],
  30. },
  31. },
  32. corePlugins: { preflight: false },
  33. }
  34. return run('@tailwind utilities', config).then((result) => {
  35. expect(result.css).toMatchFormattedCss(css`
  36. .invisible {
  37. visibility: hidden;
  38. }
  39. `)
  40. })
  41. })