|
| 1 | +import invokePlugin from '../util/invokePlugin' |
| 2 | +import plugin from '../../src/plugins/animation' |
| 3 | + |
| 4 | +test('defining animation and keyframes', () => { |
| 5 | + const config = { |
| 6 | + theme: { |
| 7 | + animation: { |
| 8 | + none: 'none', |
| 9 | + spin: 'spin 1s linear infinite', |
| 10 | + ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite', |
| 11 | + }, |
| 12 | + keyframes: { |
| 13 | + spin: { to: { transform: 'rotate(360deg)' } }, |
| 14 | + ping: { '75%, 100%': { transform: 'scale(2)', opacity: '0' } }, |
| 15 | + }, |
| 16 | + }, |
| 17 | + variants: { |
| 18 | + animation: [], |
| 19 | + }, |
| 20 | + } |
| 21 | + |
| 22 | + const { utilities } = invokePlugin(plugin(), config) |
| 23 | + |
| 24 | + expect(utilities).toEqual([ |
| 25 | + [ |
| 26 | + { |
| 27 | + '@keyframes ping': { '75%, 100%': { opacity: '0', transform: 'scale(2)' } }, |
| 28 | + '@keyframes spin': { to: { transform: 'rotate(360deg)' } }, |
| 29 | + }, |
| 30 | + { respectImportant: false }, |
| 31 | + ], |
| 32 | + [ |
| 33 | + { |
| 34 | + '.animate-none': { animation: 'none' }, |
| 35 | + '.animate-ping': { animation: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite' }, |
| 36 | + '.animate-spin': { animation: 'spin 1s linear infinite' }, |
| 37 | + }, |
| 38 | + [], |
| 39 | + ], |
| 40 | + ]) |
| 41 | +}) |
| 42 | + |
| 43 | +test('defining animation and keyframes with prefix', () => { |
| 44 | + const config = { |
| 45 | + prefix: 'tw-', |
| 46 | + theme: { |
| 47 | + animation: { |
| 48 | + none: 'none', |
| 49 | + spin: 'spin 1s linear infinite', |
| 50 | + ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite', |
| 51 | + }, |
| 52 | + keyframes: { |
| 53 | + spin: { to: { transform: 'rotate(360deg)' } }, |
| 54 | + ping: { '75%, 100%': { transform: 'scale(2)', opacity: '0' } }, |
| 55 | + }, |
| 56 | + }, |
| 57 | + variants: { |
| 58 | + animation: [], |
| 59 | + }, |
| 60 | + } |
| 61 | + |
| 62 | + const { utilities } = invokePlugin(plugin(), config) |
| 63 | + |
| 64 | + expect(utilities).toEqual([ |
| 65 | + [ |
| 66 | + { |
| 67 | + '@keyframes tw-ping': { '75%, 100%': { opacity: '0', transform: 'scale(2)' } }, |
| 68 | + '@keyframes tw-spin': { to: { transform: 'rotate(360deg)' } }, |
| 69 | + }, |
| 70 | + { respectImportant: false }, |
| 71 | + ], |
| 72 | + [ |
| 73 | + { |
| 74 | + '.animate-none': { animation: 'none' }, |
| 75 | + '.animate-ping': { animation: 'tw-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite' }, |
| 76 | + '.animate-spin': { animation: 'tw-spin 1s linear infinite' }, |
| 77 | + }, |
| 78 | + [], |
| 79 | + ], |
| 80 | + ]) |
| 81 | +}) |
0 commit comments