|
| 1 | +import { run, html, css } from '../util/run' |
| 2 | + |
| 3 | +it('should add the divide styles for divide-y and a default border color', () => { |
| 4 | + let config = { |
| 5 | + content: [{ raw: html`<div class="divide-y"></div>` }], |
| 6 | + corePlugins: { preflight: false }, |
| 7 | + } |
| 8 | + |
| 9 | + return run('@tailwind base; @tailwind utilities;', config).then((result) => { |
| 10 | + expect(result.css).toMatchCss(css` |
| 11 | + *, |
| 12 | + ::before, |
| 13 | + ::after { |
| 14 | + --tw-border-opacity: 1; |
| 15 | + border-color: rgba(229, 231, 235, var(--tw-border-opacity)); |
| 16 | + } |
| 17 | +
|
| 18 | + .divide-y > :not([hidden]) ~ :not([hidden]) { |
| 19 | + --tw-divide-y-reverse: 0; |
| 20 | + border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse))); |
| 21 | + border-bottom-width: calc(1px * var(--tw-divide-y-reverse)); |
| 22 | + } |
| 23 | + `) |
| 24 | + }) |
| 25 | +}) |
| 26 | + |
| 27 | +it('should add the divide styles for divide-x and a default border color', () => { |
| 28 | + let config = { |
| 29 | + content: [{ raw: html`<div class="divide-x"></div>` }], |
| 30 | + corePlugins: { preflight: false }, |
| 31 | + } |
| 32 | + |
| 33 | + return run('@tailwind base; @tailwind utilities;', config).then((result) => { |
| 34 | + expect(result.css).toMatchCss(css` |
| 35 | + *, |
| 36 | + ::before, |
| 37 | + ::after { |
| 38 | + --tw-border-opacity: 1; |
| 39 | + border-color: rgba(229, 231, 235, var(--tw-border-opacity)); |
| 40 | + } |
| 41 | +
|
| 42 | + .divide-x > :not([hidden]) ~ :not([hidden]) { |
| 43 | + --tw-divide-x-reverse: 0; |
| 44 | + border-right-width: calc(1px * var(--tw-divide-x-reverse)); |
| 45 | + border-left-width: calc(1px * calc(1 - var(--tw-divide-x-reverse))); |
| 46 | + } |
| 47 | + `) |
| 48 | + }) |
| 49 | +}) |
| 50 | + |
| 51 | +it('should add the divide styles for divide-y-reverse and a default border color', () => { |
| 52 | + let config = { |
| 53 | + content: [{ raw: html`<div class="divide-y-reverse"></div>` }], |
| 54 | + corePlugins: { preflight: false }, |
| 55 | + } |
| 56 | + |
| 57 | + return run('@tailwind base; @tailwind utilities;', config).then((result) => { |
| 58 | + expect(result.css).toMatchCss(css` |
| 59 | + *, |
| 60 | + ::before, |
| 61 | + ::after { |
| 62 | + --tw-border-opacity: 1; |
| 63 | + border-color: rgba(229, 231, 235, var(--tw-border-opacity)); |
| 64 | + } |
| 65 | +
|
| 66 | + .divide-y-reverse > :not([hidden]) ~ :not([hidden]) { |
| 67 | + --tw-divide-y-reverse: 1; |
| 68 | + } |
| 69 | + `) |
| 70 | + }) |
| 71 | +}) |
| 72 | + |
| 73 | +it('should add the divide styles for divide-x-reverse and a default border color', () => { |
| 74 | + let config = { |
| 75 | + content: [{ raw: html`<div class="divide-x-reverse"></div>` }], |
| 76 | + corePlugins: { preflight: false }, |
| 77 | + } |
| 78 | + |
| 79 | + return run('@tailwind base; @tailwind utilities;', config).then((result) => { |
| 80 | + expect(result.css).toMatchCss(css` |
| 81 | + *, |
| 82 | + ::before, |
| 83 | + ::after { |
| 84 | + --tw-border-opacity: 1; |
| 85 | + border-color: rgba(229, 231, 235, var(--tw-border-opacity)); |
| 86 | + } |
| 87 | +
|
| 88 | + .divide-x-reverse > :not([hidden]) ~ :not([hidden]) { |
| 89 | + --tw-divide-x-reverse: 1; |
| 90 | + } |
| 91 | + `) |
| 92 | + }) |
| 93 | +}) |
| 94 | + |
| 95 | +it('should only inject the base styles once if we use divide and border at the same time', () => { |
| 96 | + let config = { |
| 97 | + content: [{ raw: html`<div class="divide-y border-r"></div>` }], |
| 98 | + corePlugins: { preflight: false }, |
| 99 | + } |
| 100 | + |
| 101 | + return run('@tailwind base; @tailwind utilities;', config).then((result) => { |
| 102 | + expect(result.css).toMatchCss(css` |
| 103 | + *, |
| 104 | + ::before, |
| 105 | + ::after { |
| 106 | + --tw-border-opacity: 1; |
| 107 | + border-color: rgba(229, 231, 235, var(--tw-border-opacity)); |
| 108 | + } |
| 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 | + .border-r { |
| 117 | + border-right-width: 1px; |
| 118 | + } |
| 119 | + `) |
| 120 | + }) |
| 121 | +}) |
0 commit comments