|
| 1 | +const { hexToRgb, toKebabCase, withOpacityValue } = require('../src/utils'); |
| 2 | + |
| 3 | +describe('hexToRgb()', () => { |
| 4 | + it('transform six digit hex.', () => { |
| 5 | + expect(hexToRgb('#ffffff')).toEqual('255 255 255'); |
| 6 | + }); |
| 7 | + |
| 8 | + it('transform three digit hex.', () => { |
| 9 | + expect(hexToRgb('#fff')).toEqual('255 255 255'); |
| 10 | + }); |
| 11 | + |
| 12 | + it('transform six digit hex without #.', () => { |
| 13 | + expect(hexToRgb('ffffff')).toEqual('255 255 255'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('transform three digit hex without #.', () => { |
| 17 | + expect(hexToRgb('fff')).toEqual('255 255 255'); |
| 18 | + }); |
| 19 | +}); |
| 20 | + |
| 21 | +describe('toKebabCase()', () => { |
| 22 | + it('transform to camel case.', () => { |
| 23 | + expect(toKebabCase('lightBlue')).toEqual('light-blue'); |
| 24 | + }); |
| 25 | +}); |
| 26 | + |
| 27 | +describe('withOpacityValue()', () => { |
| 28 | + it('transform to modern rgb color format with opacity.', () => { |
| 29 | + expect( |
| 30 | + withOpacityValue('--color-accent-200')({ |
| 31 | + opacityValue: 0.8, |
| 32 | + }) |
| 33 | + ).toEqual('rgb(var(--color-accent-200) / 0.8)'); |
| 34 | + }); |
| 35 | + |
| 36 | + it('transform to modern rgb color format without opacity.', () => { |
| 37 | + expect( |
| 38 | + withOpacityValue('--color-accent-200')({ |
| 39 | + opacityValue: undefined, |
| 40 | + }) |
| 41 | + ).toEqual('rgb(var(--color-accent-200))'); |
| 42 | + }); |
| 43 | +}); |
0 commit comments