From de9d1268b746c8a527ae43abeb8e498062ff3b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Wed, 12 Aug 2020 11:38:39 +0200 Subject: [PATCH] Updated unit test --- .../client/back/methods/client/consumption.js | 13 +++++++----- .../methods/client/specs/consumption.spec.js | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/client/back/methods/client/consumption.js b/modules/client/back/methods/client/consumption.js index 20e158297..537efb9d1 100644 --- a/modules/client/back/methods/client/consumption.js +++ b/modules/client/back/methods/client/consumption.js @@ -18,19 +18,19 @@ module.exports = Self => { description: `If it's and integer searchs by id, otherwise it searchs by name` }, { arg: 'itemId', - type: 'Integer', + type: 'Number', description: 'Item id' }, { arg: 'categoryId', - type: 'Integer', + type: 'Number', description: 'Category id' }, { arg: 'typeId', - type: 'Integer', + type: 'Number', description: 'Item type id', }, { arg: 'buyerId', - type: 'Integer', + type: 'Number', description: 'Buyer id' }, { arg: 'from', @@ -121,6 +121,9 @@ module.exports = Self => { stmt.merge(conn.makePagination(filter)); - return conn.executeStmt(stmt); + console.log(stmt.sql); + console.log(stmt.params); + + return await conn.executeStmt(stmt); }; }; diff --git a/modules/client/back/methods/client/specs/consumption.spec.js b/modules/client/back/methods/client/specs/consumption.spec.js index e7a42a8da..474c888e3 100644 --- a/modules/client/back/methods/client/specs/consumption.spec.js +++ b/modules/client/back/methods/client/specs/consumption.spec.js @@ -37,4 +37,24 @@ describe('client consumption() filter', () => { expect(secondRow.quantity).toEqual(15); expect(thirdRow.quantity).toEqual(20); }); + + it('should return a list of tickets from the item id 4', async() => { + const ctx = { + args: { + itemId: 4 + } + }; + const filter = { + where: { + clientFk: 101 + }, + order: 'itemTypeFk, itemName, itemSize' + }; + const result = await app.models.Client.consumption(ctx, filter); + + const expectedItemId = 4; + const firstRow = result[0]; + + expect(firstRow.itemFk).toEqual(expectedItemId); + }); });