Skip to content

Commit

Permalink
added sort test
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Nov 9, 2016
1 parent 791b84c commit ceb788e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 50 deletions.
48 changes: 0 additions & 48 deletions users/npm-debug.log

This file was deleted.

21 changes: 19 additions & 2 deletions users/test/reading_test.js
Expand Up @@ -2,11 +2,15 @@ const assert = require('assert');
const User = require('../src/user');

describe('Reading users out of the database', () => {
let joe;
let joe, maria, alex, zach;

beforeEach((done) => {
alex = new User({ name: 'Alex' });
joe = new User({ name: 'Joe' });
joe.save()
maria = new User({ name: 'Maria' });
zach = new User({ name: 'Zach' });

Promise.all([joe.save(), alex.save(), maria.save(), zach.save()])
.then(() => done());
});

Expand All @@ -25,4 +29,17 @@ describe('Reading users out of the database', () => {
done();
});
});

it('can skip and limit the result set', (done) => {
User.find({})
.sort({ name: 1 })
.skip(1)
.limit(2)
.then((users) => {
assert(users.length === 2);
assert(users[0].name === 'Joe');
assert(users[1].name === 'Maria');
done();
});
});
});

0 comments on commit ceb788e

Please sign in to comment.