|
| 1 | +import invokePlugin from '../util/invokePlugin' |
| 2 | +import plugin from '../../src/plugins/ringWidth' |
| 3 | + |
| 4 | +test('ring widths', () => { |
| 5 | + const config = { |
| 6 | + theme: { |
| 7 | + ringWidth: { |
| 8 | + 4: '4px', |
| 9 | + }, |
| 10 | + ringOffsetWidth: { |
| 11 | + 4: '4px', |
| 12 | + }, |
| 13 | + ringColor: { |
| 14 | + black: '#000', |
| 15 | + }, |
| 16 | + ringOffsetColor: { |
| 17 | + white: '#fff', |
| 18 | + }, |
| 19 | + ringOpacity: { |
| 20 | + 50: '.5', |
| 21 | + }, |
| 22 | + }, |
| 23 | + variants: { |
| 24 | + ringColor: [], |
| 25 | + }, |
| 26 | + } |
| 27 | + |
| 28 | + const { utilities } = invokePlugin(plugin(), config) |
| 29 | + expect(utilities).toEqual([ |
| 30 | + [ |
| 31 | + { |
| 32 | + '*': { |
| 33 | + '--tw-ring-color': 'rgba(147, 197, 253, 0.5)', |
| 34 | + '--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)', |
| 35 | + '--tw-ring-offset-color': '#fff', |
| 36 | + '--tw-ring-offset-shadow': '0 0 #0000', |
| 37 | + '--tw-ring-offset-width': '0px', |
| 38 | + '--tw-ring-shadow': '0 0 #0000', |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + respectImportant: false, |
| 43 | + }, |
| 44 | + ], |
| 45 | + [ |
| 46 | + { |
| 47 | + '.ring-4': { |
| 48 | + '--tw-ring-offset-shadow': |
| 49 | + 'var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)', |
| 50 | + '--tw-ring-shadow': |
| 51 | + 'var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color)', |
| 52 | + 'box-shadow': |
| 53 | + 'var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)', |
| 54 | + }, |
| 55 | + '.ring-inset': { |
| 56 | + '--tw-ring-inset': 'inset', |
| 57 | + }, |
| 58 | + }, |
| 59 | + undefined, |
| 60 | + ], |
| 61 | + ]) |
| 62 | +}) |
| 63 | + |
| 64 | +test('ring widths with defaults', () => { |
| 65 | + const config = { |
| 66 | + theme: { |
| 67 | + ringWidth: {}, |
| 68 | + ringOffsetWidth: { |
| 69 | + DEFAULT: '2px', |
| 70 | + }, |
| 71 | + ringOffsetColor: { |
| 72 | + DEFAULT: 'pink', |
| 73 | + }, |
| 74 | + }, |
| 75 | + variants: { |
| 76 | + ringColor: [], |
| 77 | + }, |
| 78 | + } |
| 79 | + |
| 80 | + const { utilities } = invokePlugin(plugin(), config) |
| 81 | + expect(utilities).toEqual([ |
| 82 | + [ |
| 83 | + { |
| 84 | + '*': { |
| 85 | + '--tw-ring-color': 'rgba(147, 197, 253, 0.5)', |
| 86 | + '--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)', |
| 87 | + '--tw-ring-offset-color': 'pink', |
| 88 | + '--tw-ring-offset-shadow': '0 0 #0000', |
| 89 | + '--tw-ring-offset-width': '2px', |
| 90 | + '--tw-ring-shadow': '0 0 #0000', |
| 91 | + }, |
| 92 | + }, |
| 93 | + { respectImportant: false }, |
| 94 | + ], |
| 95 | + [ |
| 96 | + { |
| 97 | + '.ring-inset': { |
| 98 | + '--tw-ring-inset': 'inset', |
| 99 | + }, |
| 100 | + }, |
| 101 | + undefined, |
| 102 | + ], |
| 103 | + ]) |
| 104 | +}) |
0 commit comments