From 05c15281956d3c8b626bdb756e88aca6ed5c4060 Mon Sep 17 00:00:00 2001 From: gerard Date: Wed, 22 Aug 2018 08:24:54 +0200 Subject: [PATCH] Tarea #533 /sale/removes.js Backend unit tests --- .../common/methods/sale/specs/removes.spec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/services/loopback/common/methods/sale/specs/removes.spec.js b/services/loopback/common/methods/sale/specs/removes.spec.js index b78e170e3..b234eef76 100644 --- a/services/loopback/common/methods/sale/specs/removes.spec.js +++ b/services/loopback/common/methods/sale/specs/removes.spec.js @@ -1,14 +1,14 @@ const app = require(`${servicesDir}/ticket/server/server`); -const restoreFixtures = require(`${servicesDir}/db/testing_fixtures`); describe('sale removes()', () => { - let sqlStatements = {deletes: ``, inserts: ` - INSERT INTO vn2008.Movimientos (Id_Movimiento, Id_Article, Id_Ticket, Concepte, Cantidad, Preu, Descuento, CostFixat, Reservado, OK, PrecioFijado, odbc_date) VALUES ('1', '1', '1', 'Gem of Time', '5.00', '23.50', '0', '0.00', '0', '0', '0', '2018-08-20 00:00:00'); - INSERT INTO vn2008.Movimientos (Id_Movimiento, Id_Article, Id_Ticket, Concepte, Cantidad, Preu, Descuento, CostFixat, Reservado, OK, PrecioFijado, odbc_date) VALUES ('2', '2', '1', 'Gem of Mind', '10.00', '4.50', '0', '0.00', '0', '0', '0', '2018-08-20 00:00:00'); - `, updates: ``}; + let sale; - afterAll(() => { - restoreFixtures(sqlStatements); + beforeAll(async() => { + sale = await app.models.Sale.findOne({where: {id: 1}}); + }); + + afterAll(async() => { + await app.models.Sale.create(sale); }); it('should throw an error if the ticket of the given sales is not editable', async() => { @@ -30,12 +30,12 @@ describe('sale removes()', () => { it('should delete the sales', async() => { let params = { - sales: [{id: 1, instance: 0}, {id: 2, instance: 1}], + sales: [{id: 1, instance: 0}], actualTicketFk: 1 }; let res = await app.models.Sale.removes(params); - expect(res).toEqual([{count: 1}, {count: 1}]); + expect(res).toEqual([{count: 1}]); }); });