Skip to content

Commit

Permalink
Merge pull request #3 from esco/master
Browse files Browse the repository at this point in the history
kick off testing with test for hasNextPages
  • Loading branch information
niftylettuce committed Sep 4, 2014
2 parents c3a5ad5 + 646b940 commit 5b5a08c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ dwsync.xml
# ------------------------------------------------------------------------------
# Add your custom excludes below
# ------------------------------------------------------------------------------

coverage/
4 changes: 1 addition & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,4 @@ if paginate.hasPreviousPages || paginate.hasNextPages(pageCount)
a(href=paginate.href()).next
| Next 
i.fa.fa-arrow-circle-right
```


```
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"version": "0.0.2",
"description": "Node.js pagination middleware and view helpers",
"main": "./index.js",
"scripts": {
"prepublish": "npm prune"
},
"repository": {
"type": "git",
"url": "git://github.com/niftylettuce/express-paginate.git"
Expand All @@ -20,5 +17,15 @@
"lodash": "^2.4.1",
"querystring": "^0.2.0"
},
"devDependencies": {}
}
"devDependencies": {
"chai": "^1.9.1",
"istanbul": "^0.3.0",
"mocha": "^1.21.4"
},
"scripts": {
"prepublish": "npm prune",
"test": "mocha --reporter spec --bail --check-leaks --require test/support/should test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks --require test/support/should test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks --require test/support/should test/"
}
}
41 changes: 41 additions & 0 deletions test/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var paginate = require('../index');

describe('paginate', function(){

describe('.hasNextPages(req)', function(){

beforeEach(function(){
this.req = {query:{page:3}};
});

it('should return function', function(){
paginate.hasNextPages(this.req).should.be.a('function');
});

describe('the returned function', function(){

it('should return true when there are more pages', function(){
paginate.hasNextPages(this.req)(4).should.be.true;
});

it('should return false when there are no more pages', function(){
paginate.hasNextPages(this.req)(3).should.be.false;
});

it('should throw an error when pageCount is not a number', function(){
(function(){
paginate.hasNextPages(this.req)('');
}).should.throw(/not a number/);
});

it('should throw an error when pageCount is less than zero', function(){
(function(){
paginate.hasNextPages(this.req)('');
}).should.throw(/\> 0/);
});

})

});

});
2 changes: 2 additions & 0 deletions test/support/should.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var chai = require('chai');
chai.should();

0 comments on commit 5b5a08c

Please sign in to comment.