|
| 1 | +import { |
| 2 | + getPaddingLeft, |
| 3 | + getPaddingLeftFromContainer, |
| 4 | + getPaddingRight, |
| 5 | + getPaddingRightFromContainer, |
| 6 | +} from '../input.mixin.utils'; |
| 7 | + |
| 8 | +describe('getPaddingLeft', () => { |
| 9 | + it('should return undefined when padding is not provided', () => { |
| 10 | + expect(getPaddingLeft()).toBeUndefined(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should return the same value when padding is provided for all sides', () => { |
| 14 | + expect(getPaddingLeft('10px')).toBe('10px'); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should return the horizontal padding when vertical and horizontal padding are provided', () => { |
| 18 | + expect(getPaddingLeft('10px 20px')).toBe('20px'); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should return the horizontal padding when top, horizontal, and bottom padding are provided', () => { |
| 22 | + expect(getPaddingLeft('10px 20px 30px')).toBe('20px'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should return the left padding when padding is provided for all four sides', () => { |
| 26 | + expect(getPaddingLeft('10px 20px 30px 40px')).toBe('40px'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should return undefined when padding format is not recognized', () => { |
| 30 | + expect(getPaddingLeft('10px 20px 30px 40px 50px')).toBeUndefined(); |
| 31 | + }); |
| 32 | +}); |
| 33 | + |
| 34 | +describe('getPaddingRight', () => { |
| 35 | + it('should return undefined when padding is not provided', () => { |
| 36 | + expect(getPaddingRight()).toBeUndefined(); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should return the same value when padding is provided for all sides', () => { |
| 40 | + expect(getPaddingRight('10px')).toBe('10px'); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should return the horizontal padding when vertical and horizontal padding are provided', () => { |
| 44 | + expect(getPaddingRight('10px 20px')).toBe('20px'); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should return the horizontal padding when top, horizontal, and bottom padding are provided', () => { |
| 48 | + expect(getPaddingRight('10px 20px 30px')).toBe('20px'); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should return the right padding when padding is provided for all four sides', () => { |
| 52 | + expect(getPaddingRight('10px 20px 30px 40px')).toBe('20px'); |
| 53 | + }); |
| 54 | + |
| 55 | + it('should return undefined when padding format is not recognized', () => { |
| 56 | + expect(getPaddingRight('10px 20px 30px 40px 50px')).toBeUndefined(); |
| 57 | + }); |
| 58 | +}); |
| 59 | + |
| 60 | +describe('getPaddingLeftFromContainer', () => { |
| 61 | + it('should return padding_left when it is defined', () => { |
| 62 | + const container = { padding_left: '10px' }; |
| 63 | + expect(getPaddingLeftFromContainer(container)).toBe('10px'); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should return padding from getPaddingLeft when padding_left is not defined', () => { |
| 67 | + const container = { padding: '10px 20px 30px 40px' }; |
| 68 | + expect(getPaddingLeftFromContainer(container)).toBe('40px'); |
| 69 | + }); |
| 70 | + |
| 71 | + it('should return "0rem" when neither padding_left nor padding is defined', () => { |
| 72 | + const container = {}; |
| 73 | + expect(getPaddingLeftFromContainer(container)).toBe('0rem'); |
| 74 | + }); |
| 75 | +}); |
| 76 | + |
| 77 | +describe('getPaddingRightFromContainer', () => { |
| 78 | + it('should return padding_right when it is defined', () => { |
| 79 | + const container = { padding_right: '10px' }; |
| 80 | + expect(getPaddingRightFromContainer(container)).toBe('10px'); |
| 81 | + }); |
| 82 | + |
| 83 | + it('should return padding from getPaddingRight when padding_right is not defined', () => { |
| 84 | + const container = { padding: '10px 20px 30px 40px' }; |
| 85 | + expect(getPaddingRightFromContainer(container)).toBe('20px'); |
| 86 | + }); |
| 87 | + |
| 88 | + it('should return "0rem" when neither padding_right nor padding is defined', () => { |
| 89 | + const container = {}; |
| 90 | + expect(getPaddingRightFromContainer(container)).toBe('0rem'); |
| 91 | + }); |
| 92 | +}); |
0 commit comments