-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kick off testing with test for hasNextPages
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var paginate = require('../index'); | ||
var chai = require('chai'); | ||
|
||
chai.should(); | ||
|
||
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/); | ||
}); | ||
|
||
}) | ||
|
||
}); | ||
|
||
}); |