diff --git a/modules/invoiceOut/front/global-invoicing/index.js b/modules/invoiceOut/front/global-invoicing/index.js index e910368fa..8e00231ea 100644 --- a/modules/invoiceOut/front/global-invoicing/index.js +++ b/modules/invoiceOut/front/global-invoicing/index.js @@ -61,9 +61,7 @@ class Controller extends Section { }; this.$http.post(`InvoiceOuts/clientsToInvoice`, params) .then(res => { - console.log(res.data); this.addresses = res.data; - console.log(this.address); if (!this.addresses.length) throw new UserError(`There aren't tickets to invoice`); diff --git a/modules/invoiceOut/front/global-invoicing/index.spec.js b/modules/invoiceOut/front/global-invoicing/index.spec.js index fcffeb6ee..056839b20 100644 --- a/modules/invoiceOut/front/global-invoicing/index.spec.js +++ b/modules/invoiceOut/front/global-invoicing/index.spec.js @@ -1,25 +1,18 @@ import './index'; -const UserError = require('vn-loopback/util/user-error'); + describe('InvoiceOut', () => { describe('Component vnInvoiceOutGlobalInvoicing', () => { let controller; let $httpBackend; - let $httpParamSerializer; beforeEach(ngModule('invoiceOut')); - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - let $scope = $rootScope.$new(); + const $scope = $rootScope.$new(); const $element = angular.element(''); - const $transclude = { - $$boundTransclude: { - $$slots: [] - } - }; - controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope, $transclude}); - controller.$.invoiceButton = {disabled: false}; + + controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope}); })); describe('makeInvoice()', () => { @@ -56,22 +49,21 @@ describe('InvoiceOut', () => { }); it('should make an http POST query and then call to the showSuccess() method', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); const date = Date.vnNew(); - date.setDate(date.getDate() + 1); - controller.invoiceDate = date; - controller.maxShipped = date; - controller.minInvoicingDate = Date.vnNew(); - controller.clientsToInvoice = 'one'; - controller.clientId = 1101; - controller.companyFk = 442; - controller.printerFk = 1; - const response = [{ + Object.assign(controller, { + invoiceDate: date, + maxShipped: date, + minInvoicingDate: date, + clientsToInvoice: 'one', + clientId: 1101, + companyFk: 442, + printerFk: 1 + }); + $httpBackend.expectPOST(`InvoiceOuts/clientsToInvoice`).respond([{ clientId: 1101, id: 121 - }]; - $httpBackend.expect('POST', `InvoiceOuts/clientsToInvoice`).respond(response); - $httpBackend.expect('POST', `InvoiceOuts/invoiceClient`).respond(1); + }]); + $httpBackend.expectPOST(`InvoiceOuts/invoiceClient`).respond(); controller.makeInvoice(); $httpBackend.flush();