From af2803deda291f77d430630a61cbfed118bb1d83 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Thu, 4 Oct 2018 14:42:44 +0200 Subject: [PATCH] #709 PROCEDURE vn.buyUltimate() unit test --- services/db/tests/vn/buyUltimate.spec.js | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 services/db/tests/vn/buyUltimate.spec.js diff --git a/services/db/tests/vn/buyUltimate.spec.js b/services/db/tests/vn/buyUltimate.spec.js new file mode 100644 index 000000000..1eb0b4199 --- /dev/null +++ b/services/db/tests/vn/buyUltimate.spec.js @@ -0,0 +1,41 @@ +const app = require(`../../../ticket/server/server`); + +describe('buyUltimate()', () => { + const today = new Date(); + it(`should create buyUltimate temporal table and update it's values`, async() => { + let params = { + warehouseFk: 1, + date: today + }; + + let query = ` + START TRANSACTION; + CALL vn.buyUltimate(?, ?); + SELECT * FROM tmp.buyUltimate; + + ROLLBACK;`; + let result = await app.models.Ticket.rawSql(query, [ + params.warehouseFk, + params.date + ]); + + let buyUltimateTable = result[2]; + + expect(buyUltimateTable.length).toEqual(4); + + expect(buyUltimateTable[0].itemFk).toEqual(1); + expect(buyUltimateTable[1].itemFk).toEqual(2); + expect(buyUltimateTable[2].itemFk).toEqual(3); + expect(buyUltimateTable[3].itemFk).toEqual(4); + + expect(buyUltimateTable[0].warehouseFk).toEqual(1); + expect(buyUltimateTable[1].warehouseFk).toEqual(1); + expect(buyUltimateTable[2].warehouseFk).toEqual(1); + expect(buyUltimateTable[3].warehouseFk).toEqual(1); + + expect(buyUltimateTable[1].buyFk).toEqual(4); + expect(buyUltimateTable[0].buyFk).toEqual(3); + expect(buyUltimateTable[2].buyFk).toEqual(5); + expect(buyUltimateTable[3].buyFk).toEqual(6); + }); +});