|
1 | | -it.todo('write a test'); |
| 1 | +import { getShadowPropsFromStyle } from '../'; |
| 2 | + |
| 3 | +describe('getShadowPropsFromStyle function test', () => { |
| 4 | + const emptyProps = { |
| 5 | + shadowColor: undefined, |
| 6 | + shadowOffset: undefined, |
| 7 | + shadowOpacity: undefined, |
| 8 | + shadowRadius: undefined, |
| 9 | + }; |
| 10 | + const pinkColorInDecemal = 4294951115; |
| 11 | + const blackColorInDecemal = 4278190080; |
| 12 | + |
| 13 | + test('empty styles return empty object', () => { |
| 14 | + const result = getShadowPropsFromStyle({}); |
| 15 | + expect(result).toStrictEqual(emptyProps); |
| 16 | + }); |
| 17 | + |
| 18 | + test('non shadow properties returns empty object', () => { |
| 19 | + const result = getShadowPropsFromStyle({ |
| 20 | + width: 100, |
| 21 | + backgroundColor: 'blue', |
| 22 | + }); |
| 23 | + expect(result).toStrictEqual(emptyProps); |
| 24 | + }); |
| 25 | + |
| 26 | + test('shadow styles return shadow properties', () => { |
| 27 | + const result = getShadowPropsFromStyle({ |
| 28 | + shadowColor: 'pink', |
| 29 | + shadowOffset: { |
| 30 | + width: -4, |
| 31 | + height: 4, |
| 32 | + }, |
| 33 | + shadowOpacity: 1, |
| 34 | + shadowRadius: 4.65, |
| 35 | + }); |
| 36 | + expect(result).toStrictEqual({ |
| 37 | + shadowColor: pinkColorInDecemal, |
| 38 | + shadowOffset: { |
| 39 | + width: -4, |
| 40 | + height: 4, |
| 41 | + }, |
| 42 | + shadowOpacity: 1, |
| 43 | + shadowRadius: 4.65, |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + test('return black shadow property if not set but shadowOffset is presented', () => { |
| 48 | + const result = getShadowPropsFromStyle({ |
| 49 | + shadowOffset: { |
| 50 | + width: -4, |
| 51 | + height: 4, |
| 52 | + }, |
| 53 | + }); |
| 54 | + expect(result).toStrictEqual({ |
| 55 | + shadowColor: blackColorInDecemal, |
| 56 | + shadowOffset: { |
| 57 | + width: -4, |
| 58 | + height: 4, |
| 59 | + }, |
| 60 | + shadowOpacity: undefined, |
| 61 | + shadowRadius: undefined, |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + test('return black shadow property if not set but shadowOffset is presented', () => { |
| 66 | + const result = getShadowPropsFromStyle({ |
| 67 | + shadowOpacity: 1, |
| 68 | + }); |
| 69 | + expect(result).toStrictEqual({ |
| 70 | + shadowColor: blackColorInDecemal, |
| 71 | + shadowOffset: undefined, |
| 72 | + shadowOpacity: 1, |
| 73 | + shadowRadius: undefined, |
| 74 | + }); |
| 75 | + }); |
| 76 | + |
| 77 | + test('return black shadow property if not set but shadowRadius is presented', () => { |
| 78 | + const result = getShadowPropsFromStyle({ |
| 79 | + shadowRadius: 4, |
| 80 | + }); |
| 81 | + expect(result).toStrictEqual({ |
| 82 | + shadowColor: blackColorInDecemal, |
| 83 | + shadowOffset: undefined, |
| 84 | + shadowOpacity: undefined, |
| 85 | + shadowRadius: 4, |
| 86 | + }); |
| 87 | + }); |
| 88 | +}); |
0 commit comments