Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
utilPaginate (and tests) improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisallenlane committed Jun 17, 2016
1 parent c5d85c4 commit ad818d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/utilPaginate.js
Expand Up @@ -87,8 +87,8 @@ Wit(app, config, function(err, wit) {
test('paginate: page must ignore values < 1', function(t) {
t.plan(7);
var paginated = paginate(wit.posts, { page: -1 });
t.equals(paginated.posts.length , 3);
t.equals(paginated.posts[0].name , 'post-3');
t.equals(paginated.posts.length , 3);
t.equals(paginated.posts[0].name , 'post-3');
t.equals(paginated.pagination.count , 1);
t.equals(paginated.pagination.current , 1);
t.equals(paginated.pagination.next , false);
Expand All @@ -97,11 +97,15 @@ Wit(app, config, function(err, wit) {
});

test('paginate: perPage must default to 10 if invalid', function(t) {
t.plan(3);
t.plan(7);
var paginated = paginate(wit.posts, { perPage: 'foo' });
t.equals(paginated.posts.length , 3);
t.equals(paginated.posts[0].name , 'post-3');
t.equals(paginated.pagination.perPage , 10);
t.equals(paginated.posts.length , 3);
t.equals(paginated.posts[0].name , 'post-3');
t.equals(paginated.pagination.count , 1);
t.equals(paginated.pagination.current , 1);
t.equals(paginated.pagination.next , false);
t.equals(paginated.pagination.previous , false);
t.equals(paginated.pagination.perPage , 10);
});

});

0 comments on commit ad818d0

Please sign in to comment.