first implementation of fields
This commit is contained in:
@ -259,6 +259,33 @@ describe('/sample', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('returns only the fields specified', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&page-size=1&fields[]=number&fields[]=condition&fields[]=color&fields[]=material.name&fields[]=material.mineral',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 200,
|
||||
res: [{number: '1', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, color: 'black', material: {name: 'Schulamid 66 GF 25 H', mineral: 0}}]
|
||||
});
|
||||
});
|
||||
it('rejects an invalid fields parameter', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&page-size=1&fields=number',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 400,
|
||||
res: {status: 'Invalid body format', details: '"fields" must be an array'}
|
||||
});
|
||||
});
|
||||
it('rejects an unknown field name', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
url: '/samples?status=all&page-size=1&fields[]=xx',
|
||||
auth: {basic: 'janedoe'},
|
||||
httpStatus: 400,
|
||||
res: {status: 'Invalid body format', details: '"fields[0]" must be one of [_id, color, number, type, batch, added, material.name, material.supplier, material.group, material.mineral, material.glass_fiber, material.carbon_fiber, material.number, condition, material_id, note_id, user_id, material._id, material.numbers]'}
|
||||
});
|
||||
});
|
||||
it('rejects a negative page size', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'get',
|
||||
@ -302,7 +329,7 @@ describe('/sample', () => {
|
||||
httpStatus: 401
|
||||
});
|
||||
});
|
||||
});
|
||||
}); // TODO: measurement fields
|
||||
|
||||
describe('GET /samples/{state}', () => {
|
||||
it('returns all new samples', done => {
|
||||
|
Reference in New Issue
Block a user