|
| 1 | +import { heightStyle } from './height'; |
| 2 | +import { widthStyle } from './width'; |
| 3 | + |
| 4 | +const { parseStyle } = require('../utils/styles'); |
| 5 | + |
| 6 | +describe('dimensionStyle – width & height helpers', () => { |
| 7 | + test('single value width', () => { |
| 8 | + const res = widthStyle({ width: '10x' }) as any; |
| 9 | + expect(res.width).toBe('calc(10 * var(--gap))'); |
| 10 | + expect(res['min-width']).toBe('initial'); |
| 11 | + expect(res['max-width']).toBe('initial'); |
| 12 | + }); |
| 13 | + |
| 14 | + test('min & max width (two values)', () => { |
| 15 | + const res = widthStyle({ width: '1x 10x' }) as any; |
| 16 | + expect(res.width).toBe('auto'); |
| 17 | + expect(res['min-width']).toBe('var(--gap)'); |
| 18 | + expect(res['max-width']).toBe('calc(10 * var(--gap))'); |
| 19 | + }); |
| 20 | + |
| 21 | + test('min modifier width', () => { |
| 22 | + const res = widthStyle({ width: 'min 2x' }) as any; |
| 23 | + expect(res.width).toBe('auto'); |
| 24 | + expect(res['min-width']).toBe('calc(2 * var(--gap))'); |
| 25 | + expect(res['max-width']).toBe('initial'); |
| 26 | + }); |
| 27 | + |
| 28 | + test('max modifier width', () => { |
| 29 | + const res = widthStyle({ width: 'max 2x' }) as any; |
| 30 | + expect(res.width).toBe('auto'); |
| 31 | + expect(res['min-width']).toBe('initial'); |
| 32 | + expect(res['max-width']).toBe('calc(2 * var(--gap))'); |
| 33 | + }); |
| 34 | + |
| 35 | + test('stretch width keyword', () => { |
| 36 | + const res = widthStyle({ width: 'stretch' }) as any; |
| 37 | + expect(res.width).toEqual([ |
| 38 | + 'stretch', |
| 39 | + '-webkit-fill-available', |
| 40 | + '-moz-available', |
| 41 | + ]); |
| 42 | + }); |
| 43 | + |
| 44 | + test('boolean true width (auto)', () => { |
| 45 | + const res = widthStyle({ width: true }) as any; |
| 46 | + expect(res.width).toBe('auto'); |
| 47 | + }); |
| 48 | + |
| 49 | + test('responsive array width', () => { |
| 50 | + const res = widthStyle({ width: '1x 2x' }) as any; |
| 51 | + expect(res.width).toBe('auto'); |
| 52 | + expect(res['min-width']).toBe('var(--gap)'); |
| 53 | + expect(res['max-width']).toBe('calc(2 * var(--gap))'); |
| 54 | + }); |
| 55 | + |
| 56 | + test('single value height', () => { |
| 57 | + const res = heightStyle({ height: '100px' }) as any; |
| 58 | + expect(res.height).toBe('100px'); |
| 59 | + expect(res['min-height']).toBe('initial'); |
| 60 | + expect(res['max-height']).toBe('initial'); |
| 61 | + }); |
| 62 | + |
| 63 | + test('min value height three args', () => { |
| 64 | + const res = heightStyle({ height: '1x 5x 10x' }) as any; |
| 65 | + expect(res.height).toBe('calc(5 * var(--gap))'); |
| 66 | + expect(res['min-height']).toBe('var(--gap)'); |
| 67 | + expect(res['max-height']).toBe('calc(10 * var(--gap))'); |
| 68 | + }); |
| 69 | + |
| 70 | + test('boolean true height (auto)', () => { |
| 71 | + const res = heightStyle({ height: true }) as any; |
| 72 | + expect(res.height).toBe('auto'); |
| 73 | + }); |
| 74 | +}); |
0 commit comments