|
| 1 | +import parseLength from '../src/parseLength'; |
| 2 | + |
| 3 | +describe('parseLength(input)', () => { |
| 4 | + it('handles string "auto"', () => { |
| 5 | + expect(parseLength('auto')).toEqual({ isDynamic: true, multiplier: 1 }); |
| 6 | + }); |
| 7 | + |
| 8 | + it('handles strings with % at the end', () => { |
| 9 | + expect(parseLength('100%')).toEqual({ isDynamic: true, multiplier: 1 }); |
| 10 | + expect(parseLength('50%')).toEqual({ isDynamic: true, multiplier: 0.5 }); |
| 11 | + expect(parseLength('0%')).toEqual({ isDynamic: true, multiplier: 0 }); |
| 12 | + }); |
| 13 | + |
| 14 | + it('handles strings that are numbers with px at the end', () => { |
| 15 | + expect(parseLength('100px')).toEqual({ isDynamic: false, value: 100 }); |
| 16 | + expect(parseLength('20.5px')).toEqual({ isDynamic: false, value: 20.5 }); |
| 17 | + }); |
| 18 | + |
| 19 | + it('handles strings that are numbers', () => { |
| 20 | + expect(parseLength('100')).toEqual({ isDynamic: false, value: 100 }); |
| 21 | + expect(parseLength('40.5')).toEqual({ isDynamic: false, value: 40.5 }); |
| 22 | + expect(parseLength('20.0')).toEqual({ isDynamic: false, value: 20 }); |
| 23 | + }); |
| 24 | + |
| 25 | + it('handles numbers', () => { |
| 26 | + expect(parseLength(100)).toEqual({ isDynamic: false, value: 100 }); |
| 27 | + expect(parseLength(0)).toEqual({ isDynamic: false, value: 0 }); |
| 28 | + }); |
| 29 | +}); |
0 commit comments