corrade-nucleus-nucleons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | describe('checkForLastNumericKey', function() { |
2 | it('when provided with invalid objects then it returns undefined', function() { |
||
3 | expect(checkForLastNumericKey({})).toBeUndefined(); |
||
4 | expect(checkForLastNumericKey([])).toBeUndefined(); |
||
5 | expect(checkForLastNumericKey(null)).toBeUndefined(); |
||
6 | expect(checkForLastNumericKey(undefined)).toBeUndefined(); |
||
7 | }); |
||
8 | |||
9 | it('when provided with an object with only numeric keys then it returns the last numeric key', function() { |
||
10 | expect(checkForLastNumericKey({ 1:'first', 2: 'second', 3: 'third' })).toBe('3'); |
||
11 | expect(checkForLastNumericKey({ 3:'first', 2: 'second', 1: 'third' })).toBe('1'); |
||
12 | expect(checkForLastNumericKey({ 3:'first', 2: 'second', 0: 'third' })).toBe('0'); |
||
13 | }); |
||
14 | |||
15 | it('when provided with an object with mixed keys then it returns the last numeric key', function() { |
||
16 | expect(checkForLastNumericKey({ 1: 'first', 2: 'second', three: 'third' })).toBe('2'); |
||
17 | expect(checkForLastNumericKey({ 1: 'first', second: 'second', '3': 'third' })).toBe('3'); |
||
18 | }); |
||
19 | }); |