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 | import getString from './getString'; describe('getString', () => { it('should return a default value if element is null or undefined', () => { const defaultValue = ['A', 'B', 'C'].join('\\'); const nullElement = null; const undefinedElement = undefined; expect(getString(nullElement, defaultValue)).toEqual(defaultValue); expect(getString(undefinedElement, defaultValue)).toEqual(defaultValue); }); it('should return a default value if element.Value is null, undefined or not present', () => { const defaultValue = ['A', 'B', 'C'].join('\\'); const nullElement = { id: 0, Value: null, }; const undefinedElement = { id: 0, Value: undefined, }; const noValuePresentElement = { id: 0, }; expect(getString(nullElement, defaultValue)).toEqual(defaultValue); expect(getString(undefinedElement, defaultValue)).toEqual(defaultValue); expect(getString(noValuePresentElement, defaultValue)).toEqual(defaultValue); }); it('should return A,B,C,D for element when element.Value[0] = [A, B, C, D]', () => { const returnValue = ['A', 'B', 'C'].join('\\'); const element = { Value: ['A', 'B', 'C'], }; expect(getString(element, null)).toEqual(returnValue); }); it('should return 1,4,5,6 for element when element.Value[0] is [1, 4, 5, 6]', () => { const returnValue = [1, 4, 5, 6].join('\\'); const element = { Value: [1, 4, 5, 6], }; expect(getString(element, null)).toEqual(returnValue); }); it('should return A,1,3,R,7,-1 for element when element.Value is [-1, 2, 5, -10] ', () => { const returnValue = ['A', '1', '3', 'R', '7', '-1'].join('\\'); const element = { Value: ['A', '1', '3', 'R', '7', '-1'], }; expect(getString(element, null)).toEqual(returnValue); }); }); |