From 8ab6a50c73bd93e952ee4e5981d8d9ad3336278c Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Oct 2022 13:02:19 +0200 Subject: [PATCH] try to fix frontTest --- .../index/global-invoicing/index.spec.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/invoiceOut/front/index/global-invoicing/index.spec.js b/modules/invoiceOut/front/index/global-invoicing/index.spec.js index 916364007..1e5ed3a99 100644 --- a/modules/invoiceOut/front/index/global-invoicing/index.spec.js +++ b/modules/invoiceOut/front/index/global-invoicing/index.spec.js @@ -19,6 +19,7 @@ describe('InvoiceOut', () => { } }; controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope, $transclude}); + controller.$.invoiceButton = {disabled: false}; })); describe('getMinClientId()', () => { @@ -86,14 +87,39 @@ describe('InvoiceOut', () => { it('should make an http POST query and then call to the showSuccess() method', () => { jest.spyOn(controller.vnApp, 'showSuccess'); - + const filter = { + order: 'id DESC', + limit: 1 + }; + const minShipped = new Date(); + minShipped.setFullYear(minShipped.getFullYear() - 1); + minShipped.setMonth(1); + minShipped.setDate(1); + minShipped.setHours(0, 0, 0, 0); controller.invoice = { invoiceDate: new Date(), maxShipped: new Date(), fromClientId: 1101, - toClientId: 1101 + toClientId: 1101, + companyFk: 442, + minShipped: minShipped + }; + const response = { + clientsAndAddresses: [{clientId: 1101, addressId: 121}], + invoice: controller.invoice + }; + const expectedParams = { + clientId: 1101, + addressId: 121, + invoiceDate: new Date(), + maxShipped: new Date(), + companyFk: 442, + minShipped: minShipped }; + const serializedParams = $httpParamSerializer({filter}); + $httpBackend.expectGET(`Clients/findOne?${serializedParams}`).respond(200, {id: 1112}); + $httpBackend.expect('POST', `InvoiceOuts/clientToInvoice`).respond(response); $httpBackend.expect('POST', `InvoiceOuts/globalInvoicing`).respond({id: 1}); controller.responseHandler('accept'); $httpBackend.flush();