Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import getAttribute from './getAttribute'; describe('getAttribute', () => { it('should return a default value if element is null or undefined', () => { const defaultValue = '0000'; const nullElement = null; const undefinedElement = undefined; expect(getAttribute(nullElement, defaultValue)).toEqual(defaultValue); expect(getAttribute(undefinedElement, defaultValue)).toEqual(defaultValue); }); it('should return a default value if element.Value is null, undefined or not present', () => { const defaultValue = '0000'; const nullElement = { id: 0, Value: null, }; const undefinedElement = { id: 0, Value: undefined, }; const noValuePresentElement = { id: 0, }; expect(getAttribute(nullElement, defaultValue)).toEqual(defaultValue); expect(getAttribute(undefinedElement, defaultValue)).toEqual(defaultValue); expect(getAttribute(noValuePresentElement, defaultValue)).toEqual(defaultValue); }); it('should return 48 for element with value 0', () => { const returnValue = 48; const element = { Value: '0', }; expect(getAttribute(element, null)).toEqual(returnValue); }); it('should return 3211313 for element with value 11', () => { const returnValue = 3211313; const element = { Value: '11', }; expect(getAttribute(element, null)).toEqual(returnValue); }); it('should return 2.4923405222191973e+35 for element with value 00280009', () => { const returnValue = 2.4923405222191973e35; const element = { id: 0, Value: '00280009', }; expect(getAttribute(element, null)).toEqual(returnValue); }); it('should return 2949169 for element with value -1', () => { const returnValue = 2949169; const element = { id: 0, Value: '-1', }; expect(getAttribute(element, null)).toEqual(returnValue); }); }); |