| Total Complexity | 4 |
| Complexity/F | 1 |
| Lines of Code | 59 |
| Function Count | 4 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | import expect from 'expect'; |
||
| 2 | import { getCurrentRecords } from './../../src/util/getCurrentRecords'; |
||
| 3 | |||
| 4 | describe('getCurrentRecords utility function', () => { |
||
| 5 | |||
| 6 | const dataSource = { |
||
| 7 | data: [ |
||
| 8 | { |
||
| 9 | test: 'test' |
||
| 10 | }, |
||
| 11 | { |
||
| 12 | test: 'test' |
||
| 13 | }, |
||
| 14 | { |
||
| 15 | test: 'test' |
||
| 16 | }, |
||
| 17 | { |
||
| 18 | test: 'test' |
||
| 19 | }, |
||
| 20 | { |
||
| 21 | test: 'test' |
||
| 22 | }, |
||
| 23 | { |
||
| 24 | test: 'test' |
||
| 25 | }, |
||
| 26 | { |
||
| 27 | test: 'test' |
||
| 28 | }, |
||
| 29 | { |
||
| 30 | test: 'test' |
||
| 31 | }, |
||
| 32 | { |
||
| 33 | test: 'test' |
||
| 34 | }, |
||
| 35 | { |
||
| 36 | test: 'test' |
||
| 37 | }, |
||
| 38 | { |
||
| 39 | test: 'test' |
||
| 40 | } |
||
| 41 | ] |
||
| 42 | }; |
||
| 43 | |||
| 44 | it('Should return the correct set of records', () => { |
||
| 45 | expect(getCurrentRecords(dataSource, 0, 5)).toBeTruthy(); |
||
| 46 | }); |
||
| 47 | |||
| 48 | it('Should return the correct page size', () => { |
||
| 49 | expect(getCurrentRecords(dataSource, 0, 5).length).toEqual(5); |
||
| 50 | expect(getCurrentRecords(dataSource, 0, 7).length).toEqual(7); |
||
| 51 | expect(getCurrentRecords(dataSource, 0, 2).length).toEqual(2); |
||
| 52 | }); |
||
| 53 | |||
| 54 | it('Should return null', () => { |
||
| 55 | expect(getCurrentRecords(false, 0, 5)) |
||
| 56 | .toEqual(null); |
||
| 57 | }); |
||
| 58 | |||
| 59 | }); |
||
| 60 |