#1344 create test for worker filter
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat 2019-04-16 13:10:06 +02:00
parent 54f65a9227
commit 9a86929e3a
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
const app = require('vn-loopback/server/server');
describe('worker filter()', () => {
it('should return 1 result filtering by id', async() => {
let result = await app.models.Worker.filter({args: {filter: {}, search: 1}});
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(1);
});
it('should return 1 result filtering by string', async() => {
let result = await app.models.Worker.filter({args: {filter: {}, search: 'administrativeNick'}});
expect(result.length).toEqual(1);
expect(result[0].id).toEqual(5);
});
it('should return 2 results filtering by name', async() => {
let result = await app.models.Worker.filter({args: {filter: {}, name: 'agency'}});
expect(result.length).toEqual(2);
expect(result[0].nickname).toEqual('agencyNick');
expect(result[1].nickname).toEqual('agencyBossNick');
});
});