From 61e63cdd48669f822bbfbac4eebc99296d02adf0 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 2 Nov 2020 08:53:28 +0100 Subject: [PATCH] Updated unit tests --- .../back/methods/supplier/specs/getSummary.spec.js | 2 +- .../methods/supplier/specs/updateFiscalData.spec.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js index ec2e89c88..30713f517 100644 --- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -7,7 +7,7 @@ describe('Supplier getSummary()', () => { expect(supplier.id).toEqual(1); expect(supplier.name).toEqual('Plants SL'); expect(supplier.nif).toEqual('06089160W'); - expect(supplier.account).toEqual('4000000001'); + expect(supplier.account).toEqual('4100000001'); expect(supplier.payDay).toEqual(15); }); diff --git a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js index eac9fe899..84e702914 100644 --- a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js +++ b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js @@ -1,4 +1,5 @@ const app = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); describe('Supplier updateFiscalData', () => { const supplierId = 1; @@ -7,7 +8,7 @@ describe('Supplier updateFiscalData', () => { const defaultData = { name: 'Plants SL', nif: '06089160W', - account: '4000000001', + account: '4100000001', sageTaxTypeFk: 4, sageWithholdingFk: 1, sageTransactionTypeFk: 1, @@ -46,7 +47,14 @@ describe('Supplier updateFiscalData', () => { }); it('should update the supplier fiscal data and return the count if changes made', async() => { - const ctx = {req: {accessToken: {userId: administrativeId}}}; + const activeCtx = { + accessToken: {userId: administrativeId}, + }; + const ctx = {req: activeCtx}; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + ctx.args = { name: 'Weapon Dealer', nif: 'B11111111',