experimental.test.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import { run, html, css } from './util/run'
  2. test('experimental universal selector improvements (box-shadow)', () => {
  3. let config = {
  4. experimental: 'all',
  5. content: [{ raw: html`<div class="resize shadow"></div>` }],
  6. corePlugins: { preflight: false },
  7. }
  8. let input = css`
  9. @tailwind base;
  10. @tailwind utilities;
  11. `
  12. return run(input, config).then((result) => {
  13. expect(result.css).toMatchCss(css`
  14. .shadow {
  15. --tw-ring-offset-shadow: 0 0 #0000;
  16. --tw-ring-shadow: 0 0 #0000;
  17. --tw-shadow: 0 0 #0000;
  18. --tw-shadow-colored: 0 0 #0000;
  19. }
  20. .resize {
  21. resize: both;
  22. }
  23. .shadow {
  24. --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  25. --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color),
  26. 0 1px 2px -1px var(--tw-shadow-color);
  27. box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
  28. var(--tw-shadow);
  29. }
  30. `)
  31. })
  32. })
  33. test('experimental universal selector improvements (pseudo hover)', () => {
  34. let config = {
  35. experimental: 'all',
  36. content: [{ raw: html`<div class="resize hover:shadow"></div>` }],
  37. corePlugins: { preflight: false },
  38. }
  39. let input = css`
  40. @tailwind base;
  41. @tailwind utilities;
  42. `
  43. return run(input, config).then((result) => {
  44. expect(result.css).toMatchCss(css`
  45. .hover\:shadow {
  46. --tw-ring-offset-shadow: 0 0 #0000;
  47. --tw-ring-shadow: 0 0 #0000;
  48. --tw-shadow: 0 0 #0000;
  49. --tw-shadow-colored: 0 0 #0000;
  50. }
  51. .resize {
  52. resize: both;
  53. }
  54. .hover\:shadow:hover {
  55. --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  56. --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color),
  57. 0 1px 2px -1px var(--tw-shadow-color);
  58. box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
  59. var(--tw-shadow);
  60. }
  61. `)
  62. })
  63. })
  64. test('experimental universal selector improvements (multiple classes: group)', () => {
  65. let config = {
  66. experimental: 'all',
  67. content: [{ raw: html`<div class="resize group-hover:shadow"></div>` }],
  68. corePlugins: { preflight: false },
  69. }
  70. let input = css`
  71. @tailwind base;
  72. @tailwind utilities;
  73. `
  74. return run(input, config).then((result) => {
  75. expect(result.css).toMatchCss(css`
  76. .group-hover\:shadow {
  77. --tw-ring-offset-shadow: 0 0 #0000;
  78. --tw-ring-shadow: 0 0 #0000;
  79. --tw-shadow: 0 0 #0000;
  80. --tw-shadow-colored: 0 0 #0000;
  81. }
  82. .resize {
  83. resize: both;
  84. }
  85. .group:hover .group-hover\:shadow {
  86. --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  87. --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color),
  88. 0 1px 2px -1px var(--tw-shadow-color);
  89. box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
  90. var(--tw-shadow);
  91. }
  92. `)
  93. })
  94. })
  95. test('experimental universal selector improvements (child selectors: divide-y)', () => {
  96. let config = {
  97. experimental: 'all',
  98. content: [{ raw: html`<div class="resize divide-y"></div>` }],
  99. corePlugins: { preflight: false },
  100. }
  101. let input = css`
  102. @tailwind base;
  103. @tailwind utilities;
  104. `
  105. return run(input, config).then((result) => {
  106. expect(result.css).toMatchCss(css`
  107. .resize {
  108. resize: both;
  109. }
  110. .divide-y > :not([hidden]) ~ :not([hidden]) {
  111. --tw-divide-y-reverse: 0;
  112. border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
  113. border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
  114. }
  115. `)
  116. })
  117. })
  118. test('experimental universal selector improvements (hover:divide-y)', () => {
  119. let config = {
  120. experimental: 'all',
  121. content: [{ raw: html`<div class="resize hover:divide-y"></div>` }],
  122. corePlugins: { preflight: false },
  123. }
  124. let input = css`
  125. @tailwind base;
  126. @tailwind utilities;
  127. `
  128. return run(input, config).then((result) => {
  129. expect(result.css).toMatchCss(css`
  130. .resize {
  131. resize: both;
  132. }
  133. .hover\:divide-y:hover > :not([hidden]) ~ :not([hidden]) {
  134. --tw-divide-y-reverse: 0;
  135. border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
  136. border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
  137. }
  138. `)
  139. })
  140. })
  141. test('experimental universal selector improvements (#app important)', () => {
  142. let config = {
  143. experimental: 'all',
  144. important: '#app',
  145. content: [{ raw: html`<div class="resize divide-y shadow"></div>` }],
  146. corePlugins: { preflight: false },
  147. }
  148. let input = css`
  149. @tailwind base;
  150. @tailwind utilities;
  151. `
  152. return run(input, config).then((result) => {
  153. expect(result.css).toMatchCss(css`
  154. .shadow {
  155. --tw-ring-offset-shadow: 0 0 #0000;
  156. --tw-ring-shadow: 0 0 #0000;
  157. --tw-shadow: 0 0 #0000;
  158. --tw-shadow-colored: 0 0 #0000;
  159. }
  160. #app .resize {
  161. resize: both;
  162. }
  163. #app .divide-y > :not([hidden]) ~ :not([hidden]) {
  164. --tw-divide-y-reverse: 0;
  165. border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
  166. border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
  167. }
  168. #app .shadow {
  169. --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  170. --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color),
  171. 0 1px 2px -1px var(--tw-shadow-color);
  172. box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
  173. var(--tw-shadow);
  174. }
  175. `)
  176. })
  177. })