|
| 1 | +import { |
| 2 | + compileCSS, |
| 3 | + cssClassRegExp, |
| 4 | + cssKeyframesRegExp, |
| 5 | + // legacyTransform3DValue, |
| 6 | +} from '../../../../jest/utils' |
| 7 | + |
| 8 | +const testClassNames = [ |
| 9 | + 'animate-bounce-and-spin-x', |
| 10 | + 'animate-bounce-and-spin-y-2', |
| 11 | + '-animate-bounce-and-spin-z-4', |
| 12 | +] |
| 13 | +const testElements = testClassNames |
| 14 | + .map((className) => `<div class="${className}"></div>`) |
| 15 | + .join('') |
| 16 | + |
| 17 | +describe('css-animations', () => { |
| 18 | + describe('BounceAndSpin', () => { |
| 19 | + it('compiles', async () => { |
| 20 | + const css = await compileCSS(testElements) |
| 21 | + |
| 22 | + expect(css).toMatch( |
| 23 | + cssKeyframesRegExp('bounce-and-spin-x', [ |
| 24 | + [ |
| 25 | + '0%, 100%', |
| 26 | + [ |
| 27 | + 'translate: 0px var(--tw-translate-y) var(--tw-translate-z)', |
| 28 | + 'animation-timing-function: cubic-bezier(0, 0, 0.2, 1)', |
| 29 | + ], |
| 30 | + ], |
| 31 | + [ |
| 32 | + '0%, 5%', |
| 33 | + [ |
| 34 | + '--webkit-transform: rotateX(0deg) rotateY(var(--tw-rotate-y)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 35 | + 'transform: rotateX(0deg) rotateY(var(--tw-rotate-y)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 36 | + 'animation-timing-function: ease-in', |
| 37 | + ], |
| 38 | + ], |
| 39 | + [ |
| 40 | + '50%', |
| 41 | + [ |
| 42 | + 'translate: 0.25rem var(--tw-translate-y) var(--tw-translate-z)', |
| 43 | + 'animation-timing-function: cubic-bezier(0.8, 0, 1, 1)', |
| 44 | + ], |
| 45 | + ], |
| 46 | + [ |
| 47 | + '50.1%', |
| 48 | + [ |
| 49 | + '--webkit-transform: rotateX(180deg) rotateY(var(--tw-rotate-y)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 50 | + 'transform: rotateX(180deg) rotateY(var(--tw-rotate-y)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 51 | + 'animation-timing-function: linear', |
| 52 | + ], |
| 53 | + ], |
| 54 | + [ |
| 55 | + '95%, 100%', |
| 56 | + [ |
| 57 | + '--webkit-transform: rotateX(360deg) rotateY(var(--tw-rotate-y)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 58 | + 'transform: rotateX(360deg) rotateY(var(--tw-rotate-y)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 59 | + 'animation-timing-function: ease-out', |
| 60 | + ], |
| 61 | + ], |
| 62 | + ]) |
| 63 | + ) |
| 64 | + expect(css).toMatch( |
| 65 | + cssClassRegExp( |
| 66 | + 'animate-bounce-and-spin-x', |
| 67 | + 'animation: bounce-and-spin-x 1s infinite' |
| 68 | + ) |
| 69 | + ) |
| 70 | + |
| 71 | + expect(css).toMatch( |
| 72 | + cssKeyframesRegExp('bounce-and-spin-y-2', [ |
| 73 | + [ |
| 74 | + '0%, 100%', |
| 75 | + [ |
| 76 | + 'translate: var(--tw-translate-x) 0px var(--tw-translate-z)', |
| 77 | + 'animation-timing-function: cubic-bezier(0, 0, 0.2, 1)', |
| 78 | + ], |
| 79 | + ], |
| 80 | + [ |
| 81 | + '0%, 5%', |
| 82 | + [ |
| 83 | + '--webkit-transform: rotateX(var(--tw-rotate-x)) rotateY(0deg) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 84 | + 'transform: rotateX(var(--tw-rotate-x)) rotateY(0deg) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 85 | + 'animation-timing-function: ease-in', |
| 86 | + ], |
| 87 | + ], |
| 88 | + [ |
| 89 | + '50%', |
| 90 | + [ |
| 91 | + 'translate: var(--tw-translate-x) 0.5rem var(--tw-translate-z)', |
| 92 | + 'animation-timing-function: cubic-bezier(0.8, 0, 1, 1)', |
| 93 | + ], |
| 94 | + ], |
| 95 | + [ |
| 96 | + '50.1%', |
| 97 | + [ |
| 98 | + '--webkit-transform: rotateX(var(--tw-rotate-x)) rotateY(180deg) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 99 | + 'transform: rotateX(var(--tw-rotate-x)) rotateY(180deg) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 100 | + 'animation-timing-function: linear', |
| 101 | + ], |
| 102 | + ], |
| 103 | + [ |
| 104 | + '95%, 100%', |
| 105 | + [ |
| 106 | + '--webkit-transform: rotateX(var(--tw-rotate-x)) rotateY(360deg) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 107 | + 'transform: rotateX(var(--tw-rotate-x)) rotateY(360deg) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))', |
| 108 | + 'animation-timing-function: ease-out', |
| 109 | + ], |
| 110 | + ], |
| 111 | + ]) |
| 112 | + ) |
| 113 | + expect(css).toMatch( |
| 114 | + cssClassRegExp( |
| 115 | + 'animate-bounce-and-spin-y-2', |
| 116 | + 'animation: bounce-and-spin-y-2 1.19s infinite' |
| 117 | + ) |
| 118 | + ) |
| 119 | + |
| 120 | + expect(css).toMatch( |
| 121 | + cssKeyframesRegExp('-bounce-and-spin-z-4', [ |
| 122 | + [ |
| 123 | + '0%, 100%', |
| 124 | + [ |
| 125 | + 'translate: var(--tw-translate-x) var(--tw-translate-y) 0px', |
| 126 | + 'animation-timing-function: cubic-bezier(0, 0, 0.2, 1)', |
| 127 | + ], |
| 128 | + ], |
| 129 | + ['0%, 5%', ['rotate: 0deg', 'animation-timing-function: ease-in']], |
| 130 | + [ |
| 131 | + '50%', |
| 132 | + [ |
| 133 | + 'translate: var(--tw-translate-x) var(--tw-translate-y) -1rem', |
| 134 | + 'animation-timing-function: cubic-bezier(0.8, 0, 1, 1)', |
| 135 | + ], |
| 136 | + ], |
| 137 | + ['50.1%', ['rotate: -180deg', 'animation-timing-function: linear']], |
| 138 | + [ |
| 139 | + '95%, 100%', |
| 140 | + ['rotate: -360deg', 'animation-timing-function: ease-out'], |
| 141 | + ], |
| 142 | + ]) |
| 143 | + ) |
| 144 | + expect(css).toMatch( |
| 145 | + cssClassRegExp( |
| 146 | + '-animate-bounce-and-spin-z-4', |
| 147 | + 'animation: -bounce-and-spin-z-4 1.41s infinite' |
| 148 | + ) |
| 149 | + ) |
| 150 | + }) |
| 151 | + |
| 152 | + // There is no "legacy" version of BounceAndSpin |
| 153 | + }) |
| 154 | +}) |
0 commit comments