Archived
2

sorting for direct sample properties added

This commit is contained in:
VLE2FE
2020-06-26 09:38:28 +02:00
parent 49f7a475b7
commit 43413001e9
4 changed files with 101 additions and 15 deletions

View File

@ -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',