custom-separator.test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { run, html, css } from './util/run'
  2. test('custom separator', () => {
  3. let config = {
  4. darkMode: 'class',
  5. content: [
  6. {
  7. raw: html`
  8. <div class="md_hover_text-right"></div>
  9. <div class="motion-safe_hover_text-center"></div>
  10. <div class="dark_focus_text-left"></div>
  11. <div class="group-hover_focus-within_text-left"></div>
  12. <div class="rtl_active_text-center"></div>
  13. `,
  14. },
  15. ],
  16. separator: '_',
  17. }
  18. return run('@tailwind utilities', config).then((result) => {
  19. expect(result.css).toMatchFormattedCss(css`
  20. .group:hover .group-hover_focus-within_text-left:focus-within {
  21. text-align: left;
  22. }
  23. :is([dir='rtl'] .rtl_active_text-center:active) {
  24. text-align: center;
  25. }
  26. @media (prefers-reduced-motion: no-preference) {
  27. .motion-safe_hover_text-center:hover {
  28. text-align: center;
  29. }
  30. }
  31. :is(.dark .dark_focus_text-left:focus) {
  32. text-align: left;
  33. }
  34. @media (min-width: 768px) {
  35. .md_hover_text-right:hover {
  36. text-align: right;
  37. }
  38. }
  39. `)
  40. })
  41. })
  42. test('dash is not supported', () => {
  43. let config = {
  44. darkMode: 'class',
  45. content: [{ raw: 'lg-hover-font-bold' }],
  46. separator: '-',
  47. }
  48. return expect(run('@tailwind utilities', config)).rejects.toThrowError(
  49. "The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
  50. )
  51. })