important-modifier.test.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { run, css, html } from './util/run'
  2. test('important modifier', () => {
  3. let config = {
  4. important: false,
  5. darkMode: 'class',
  6. content: [
  7. {
  8. raw: html`
  9. <div class="!container"></div>
  10. <div class="!font-bold"></div>
  11. <div class="hover:!text-center"></div>
  12. <div class="lg:!opacity-50"></div>
  13. <div class="xl:focus:disabled:!float-right"></div>
  14. <div class="!custom-parent-5"></div>
  15. `,
  16. },
  17. ],
  18. corePlugins: { preflight: false },
  19. plugins: [
  20. function ({ theme, matchUtilities }) {
  21. matchUtilities(
  22. {
  23. 'custom-parent': (value) => {
  24. return {
  25. '.custom-child': {
  26. margin: value,
  27. },
  28. }
  29. },
  30. },
  31. { values: theme('spacing') }
  32. )
  33. },
  34. ],
  35. }
  36. let input = css`
  37. @tailwind components;
  38. @tailwind utilities;
  39. `
  40. return run(input, config).then((result) => {
  41. expect(result.css).toMatchFormattedCss(css`
  42. .\!container {
  43. width: 100% !important;
  44. }
  45. @media (min-width: 640px) {
  46. .\!container {
  47. max-width: 640px !important;
  48. }
  49. }
  50. @media (min-width: 768px) {
  51. .\!container {
  52. max-width: 768px !important;
  53. }
  54. }
  55. @media (min-width: 1024px) {
  56. .\!container {
  57. max-width: 1024px !important;
  58. }
  59. }
  60. @media (min-width: 1280px) {
  61. .\!container {
  62. max-width: 1280px !important;
  63. }
  64. }
  65. @media (min-width: 1536px) {
  66. .\!container {
  67. max-width: 1536px !important;
  68. }
  69. }
  70. .\!font-bold {
  71. font-weight: 700 !important;
  72. }
  73. .\!custom-parent-5 .custom-child {
  74. margin: 1.25rem !important;
  75. }
  76. .hover\:\!text-center:hover {
  77. text-align: center !important;
  78. }
  79. @media (min-width: 1024px) {
  80. .lg\:\!opacity-50 {
  81. opacity: 0.5 !important;
  82. }
  83. }
  84. @media (min-width: 1280px) {
  85. .xl\:focus\:disabled\:\!float-right:disabled:focus {
  86. float: right !important;
  87. }
  88. }
  89. `)
  90. })
  91. })