From 9a86929e3a1e98cf01a1b7307ad192b7ccbc8f0c Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 16 Apr 2019 13:10:06 +0200 Subject: [PATCH] #1344 create test for worker filter --- .../back/methods/worker/specs/filter.spec.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 modules/worker/back/methods/worker/specs/filter.spec.js diff --git a/modules/worker/back/methods/worker/specs/filter.spec.js b/modules/worker/back/methods/worker/specs/filter.spec.js new file mode 100644 index 000000000..c1bc05ae8 --- /dev/null +++ b/modules/worker/back/methods/worker/specs/filter.spec.js @@ -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'); + }); +});