sorting for direct sample properties added
This commit is contained in:
@ -177,6 +177,59 @@ describe('/sample', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('sorts the samples ascending', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&sort=color-asc',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200
|
||||
}).end((err, res) => {
|
||||
if (err) return done(err);
|
||||
should(res.body[0]).have.property('color', 'black');
|
||||
should(res.body[res.body.length - 1]).have.property('color', 'natural');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('sorts the samples descending', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&sort=number-desc',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200
|
||||
}).end((err, res) => {
|
||||
if (err) return done(err);
|
||||
should(res.body[0]).have.property('number', 'Rng36');
|
||||
should(res.body[1]).have.property('number', '33');
|
||||
should(res.body[res.body.length - 1]).have.property('number', '1');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('sorts the samples correctly in combination with paging', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&sort=color-asc&page-size=2&from-id=400000000000000000000006',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200
|
||||
}).end((err, res) => {
|
||||
if (err) return done(err);
|
||||
should(res.body[0]).have.property('_id', '400000000000000000000006');
|
||||
should(res.body[1]).have.property('_id', '400000000000000000000002');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('sorts the samples correctly in combination with going pages backward', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&sort=color-desc&page-size=2&from-id=400000000000000000000004&to-page=-1',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200
|
||||
}).end((err, res) => {
|
||||
if (err) return done(err);
|
||||
should(res.body[0]).have.property('_id', '400000000000000000000002');
|
||||
should(res.body[1]).have.property('_id', '400000000000000000000006');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('rejects a negative page size', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
|
Reference in New Issue
Block a user