added notes.comment field and filter
This commit is contained in:
@ -402,6 +402,45 @@ describe('/sample', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('filters for empty comments', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status[]=new&status[]=validated&fields[]=number&fields[]=notes.comment&filters[]=%7B%22mode%22%3A%22in%22%2C%22field%22%3A%22notes.comment%22%2C%22values%22%3A%5Bnull%2C%22%22%5D%7D',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200
|
||||
}).end((err, res) => {
|
||||
if (err) return done(err);
|
||||
const json = require('../test/db.json');
|
||||
should(res.body).have.lengthOf(
|
||||
json.collections.samples
|
||||
.filter(e => e.status !== 'deleted')
|
||||
.filter(e => e.note_id === null || json.collections.notes.find(el => el._id.toString() == e.note_id.toString()).comment === '')
|
||||
.length
|
||||
);
|
||||
should(res.body).matchEach(sample => {
|
||||
should(sample.notes.comment).be.equalOneOf(null, '');
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('returns comment fields', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status[]=new&status[]=validated&fields[]=number&fields[]=notes.comment',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200
|
||||
}).end((err, res) => {
|
||||
if (err) return done(err);
|
||||
console.log(res.body);
|
||||
const json = require('../test/db.json');
|
||||
should(res.body).have.lengthOf(json.collections.samples.filter(e => e.status !== 'deleted').length);
|
||||
should(res.body).matchEach(sample => {
|
||||
should(sample).have.only.keys('number', 'notes');
|
||||
should(sample.notes).have.only.keys('comment');
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('rejects returning spectral data for a write user', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
|
Reference in New Issue
Block a user