-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathsimplePagination.spec.js
48 lines (33 loc) · 968 Bytes
/
simplePagination.spec.js
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
'use strict';
describe('simplePagination', function() {
var pagination;
// load the app
beforeEach(module('simplePagination'));
// get service
beforeEach(inject(function(Pagination) {
pagination = Pagination.getNew();
}));
it('should paginate', function() {
pagination.numPages = 2;
expect(pagination.page).toBe(0);
pagination.nextPage();
expect(pagination.page).toBe(1);
pagination.prevPage();
expect(pagination.page).toBe(0);
});
it('should not paginate outside min and max page', function() {
pagination.numPages = 2;
pagination.page = 0;
pagination.prevPage();
expect(pagination.page).toBe(0);
pagination.page = 1;
pagination.nextPage();
expect(pagination.page).toBe(1);
});
it('should jump to a given page id', function() {
pagination.numPages = 3;
expect(pagination.page).toBe(0);
pagination.toPageId(2);
expect(pagination.page).toBe(2);
});
});