divide.test.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { run, html, css, defaults } from '../util/run'
  2. it('should add the divide styles for divide-y and a default border color', () => {
  3. let config = {
  4. content: [{ raw: html`<div class="divide-y"></div>` }],
  5. corePlugins: { preflight: false },
  6. }
  7. return run('@tailwind base; @tailwind utilities;', config).then((result) => {
  8. expect(result.css).toMatchCss(css`
  9. ${defaults}
  10. .divide-y > :not([hidden]) ~ :not([hidden]) {
  11. --tw-divide-y-reverse: 0;
  12. border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
  13. border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
  14. }
  15. `)
  16. })
  17. })
  18. it('should add the divide styles for divide-x and a default border color', () => {
  19. let config = {
  20. content: [{ raw: html`<div class="divide-x"></div>` }],
  21. corePlugins: { preflight: false },
  22. }
  23. return run('@tailwind base; @tailwind utilities;', config).then((result) => {
  24. expect(result.css).toMatchCss(css`
  25. ${defaults}
  26. .divide-x > :not([hidden]) ~ :not([hidden]) {
  27. --tw-divide-x-reverse: 0;
  28. border-right-width: calc(1px * var(--tw-divide-x-reverse));
  29. border-left-width: calc(1px * calc(1 - var(--tw-divide-x-reverse)));
  30. }
  31. `)
  32. })
  33. })
  34. it('should add the divide styles for divide-y-reverse and a default border color', () => {
  35. let config = {
  36. content: [{ raw: html`<div class="divide-y-reverse"></div>` }],
  37. corePlugins: { preflight: false },
  38. }
  39. return run('@tailwind base; @tailwind utilities;', config).then((result) => {
  40. expect(result.css).toMatchCss(css`
  41. ${defaults}
  42. .divide-y-reverse > :not([hidden]) ~ :not([hidden]) {
  43. --tw-divide-y-reverse: 1;
  44. }
  45. `)
  46. })
  47. })
  48. it('should add the divide styles for divide-x-reverse and a default border color', () => {
  49. let config = {
  50. content: [{ raw: html`<div class="divide-x-reverse"></div>` }],
  51. corePlugins: { preflight: false },
  52. }
  53. return run('@tailwind base; @tailwind utilities;', config).then((result) => {
  54. expect(result.css).toMatchCss(css`
  55. ${defaults}
  56. .divide-x-reverse > :not([hidden]) ~ :not([hidden]) {
  57. --tw-divide-x-reverse: 1;
  58. }
  59. `)
  60. })
  61. })
  62. it('should only inject the base styles once if we use divide and border at the same time', () => {
  63. let config = {
  64. content: [{ raw: html`<div class="divide-y border-r"></div>` }],
  65. corePlugins: { preflight: false },
  66. }
  67. return run('@tailwind base; @tailwind utilities;', config).then((result) => {
  68. expect(result.css).toMatchCss(css`
  69. ${defaults}
  70. .divide-y > :not([hidden]) ~ :not([hidden]) {
  71. --tw-divide-y-reverse: 0;
  72. border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
  73. border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
  74. }
  75. .border-r {
  76. border-right-width: 1px;
  77. }
  78. `)
  79. })
  80. })