-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpaginate.spec.ts
41 lines (36 loc) · 1.22 KB
/
paginate.spec.ts
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
import { User } from './data/models'
import { odataQuery } from '../src'
describe('testing ODataQuery paginate', () => {
it('paginate', () => {
const query = odataQuery<User>()
const actual = query.paginate(10).toString()
const expected = '$top=10&$count=true'
expect(actual).toBe(expected)
})
it('paginate with skip', () => {
const query = odataQuery<User>()
const actual = query.paginate(25, 5).toString()
const expected = '$skip=125&$top=25&$count=true'
expect(actual).toBe(expected)
})
it('paginate object', () => {
const query = odataQuery<User>()
const actual = query.paginate({ pagesize: 10 }).toString()
const expected = '$top=10&$count=true'
expect(actual).toBe(expected)
})
it('paginate object with skip', () => {
const query = odataQuery<User>()
const actual = query.paginate({ page: 5, pagesize: 25 }).toString()
const expected = '$skip=125&$top=25&$count=true'
expect(actual).toBe(expected)
})
it('paginate disable count', () => {
const query = odataQuery<User>()
const actual = query
.paginate({ page: 5, pagesize: 25, count: false })
.toString()
const expected = '$skip=125&$top=25'
expect(actual).toBe(expected)
})
})