Debian Codegraph @

example/PaginateMixinSpec.js

raw symbols SCIP
1 window.MyMixinSpecs = {};
2 MyMixinSpecs.PaginateMixinSpec = function(context) {
3 describe("[Pagination]", function() {
4 var view, numberOfPages, ensureOnPage;
5
6 beforeEach(function() {
7 view = context.view;
8 numberOfPages = context.numberOfPages;
9 ensureOnPage = context.ensureOnPage;
10 });
11
12 describe("The Contract", function() {
13 it("should implement numberOfPages", function() {
14 expect(view.numberOfPages).toBeTruthy();
15 expect(view.numberOfPages()).toEqual(numberOfPages);
16 });
17
18 it("should implement renderCurrentPage", function() {
19 expect(view.renderCurrentPage).toBeTruthy();
20 view.renderCurrentPage(0);
21 ensureOnPage(0);
22 });
23 });
24
25 describe("jumping to a particular page", function() {
26 describe("when the page is in bounds", function() {
27 it("should jump to the specified page", function() {
28 view.goToPage(0);
29 ensureOnPage(0);
30 view.goToPage(numberOfPages - 1);
31 ensureOnPage(numberOfPages - 1);
32 });
33 });
34
35 describe("when the page is out of bounds", function() {
36 it("should jump to the nearest legal page", function() {
37 view.goToPage(-1);
38 ensureOnPage(0);
39 view.goToPage(numberOfPages);
40 ensureOnPage(numberOfPages - 1);
41 });
42 });
43 });
44
45 describe("clicking between pages", function() {
46 it("should allow the user to go to the next/previous page and hide/show the next/previous buttons appropriately", function() {
47 view.goToPage(0);
48 expect(view.$('.previous').hasClass('hidden')).toBeTruthy();
49
50 view.$('.next').click();
51 ensureOnPage(1);
52 expect(view.$('.previous').hasClass('hidden')).toBeFalsy();
53
54 view.goToPage(numberOfPages - 1);
55 ensureOnPage(numberOfPages - 1);
56 expect(view.$('.next').hasClass('hidden')).toBeTruthy();
57 expect(view.$('.previous').hasClass('hidden')).toBeFalsy();
58
59 view.$('.previous').click();
60 ensureOnPage(numberOfPages - 2);
61 expect(view.$('.next').hasClass('hidden')).toBeFalsy();
62 });
63 })
64 });
65 }