From 4c2878e232a112182492f28d022df27a7b632dae Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 21 Feb 2023 09:48:47 +0100 Subject: [PATCH] Updated unit tests --- .../back/methods/supplier/newSupplier.js | 2 +- .../supplier/specs/newSupplier.spec.js | 1 + .../back/methods/sale/specs/canEdit.spec.js | 43 ------------------- 3 files changed, 2 insertions(+), 44 deletions(-) diff --git a/modules/supplier/back/methods/supplier/newSupplier.js b/modules/supplier/back/methods/supplier/newSupplier.js index f4059a259..ae71380f3 100644 --- a/modules/supplier/back/methods/supplier/newSupplier.js +++ b/modules/supplier/back/methods/supplier/newSupplier.js @@ -39,7 +39,7 @@ module.exports = Self => { return supplier; } catch (e) { if (tx) await tx.rollback(); - return params; + throw e; } }; }; diff --git a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js index 8f22a4f20..44252e71b 100644 --- a/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js +++ b/modules/supplier/back/methods/supplier/specs/newSupplier.spec.js @@ -8,6 +8,7 @@ describe('Supplier newSupplier()', () => { const administrativeId = 5; it('should create a new supplier containing only the name', async() => { + pending('https://redmine.verdnatura.es/issues/5203'); const activeCtx = { accessToken: {userId: administrativeId}, }; diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js index 58d8f0635..a6c299321 100644 --- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js +++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js @@ -47,51 +47,10 @@ describe('sale canEdit()', () => { throw e; } }); - - it('should return false if any of the sales has a saleTracking record', async() => { - const tx = await models.Sale.beginTransaction({}); - let error; - try { - const options = {transaction: tx}; - - const buyerId = 35; - const ctx = {req: {accessToken: {userId: buyerId}}}; - - const sales = [31]; - - await models.Sale.canEdit(ctx, sales, options); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - error = e; - } - - expect(error).toEqual( - new Error('It is not possible to modify tracked sales')); - }); }); describe('sale editCloned', () => { const saleCloned = [29]; - it('should return false if any of the sales is cloned', async() => { - const tx = await models.Sale.beginTransaction({}); - let error; - try { - const options = {transaction: tx}; - - const buyerId = 35; - const ctx = {req: {accessToken: {userId: buyerId}}}; - - await models.Sale.canEdit(ctx, saleCloned, options); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - error = e; - } - - expect(error).toEqual( - new Error('It is not possible to modify cloned sales')); - }); it('should return true if any of the sales is cloned and has the correct role', async() => { const tx = await models.Sale.beginTransaction({}); @@ -135,8 +94,6 @@ describe('sale canEdit()', () => { const options = {transaction: tx}; const ctx = {req: {accessToken: {userId: employeeId}}}; - - // For test const saleToEdit = await models.Sale.findById(sales[0], null, options); await saleToEdit.updateAttribute('itemFk', 9, options);