refs #5000 Invoicing: front tests refactor & fixes
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2023-02-23 09:45:15 +01:00
parent 4cc6485cbd
commit 7f60335a91
2 changed files with 17 additions and 27 deletions

View File

@ -61,9 +61,7 @@ class Controller extends Section {
}; };
this.$http.post(`InvoiceOuts/clientsToInvoice`, params) this.$http.post(`InvoiceOuts/clientsToInvoice`, params)
.then(res => { .then(res => {
console.log(res.data);
this.addresses = res.data; this.addresses = res.data;
console.log(this.address);
if (!this.addresses.length) if (!this.addresses.length)
throw new UserError(`There aren't tickets to invoice`); throw new UserError(`There aren't tickets to invoice`);

View File

@ -1,25 +1,18 @@
import './index'; import './index';
const UserError = require('vn-loopback/util/user-error');
describe('InvoiceOut', () => { describe('InvoiceOut', () => {
describe('Component vnInvoiceOutGlobalInvoicing', () => { describe('Component vnInvoiceOutGlobalInvoicing', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;
let $httpParamSerializer;
beforeEach(ngModule('invoiceOut')); beforeEach(ngModule('invoiceOut'));
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_; const $scope = $rootScope.$new();
let $scope = $rootScope.$new();
const $element = angular.element('<vn-invoice-out-global-invoicing></vn-invoice-out-global-invoicing>'); const $element = angular.element('<vn-invoice-out-global-invoicing></vn-invoice-out-global-invoicing>');
const $transclude = {
$$boundTransclude: { controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope});
$$slots: []
}
};
controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope, $transclude});
controller.$.invoiceButton = {disabled: false};
})); }));
describe('makeInvoice()', () => { describe('makeInvoice()', () => {
@ -56,22 +49,21 @@ describe('InvoiceOut', () => {
}); });
it('should make an http POST query and then call to the showSuccess() method', () => { it('should make an http POST query and then call to the showSuccess() method', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
const date = Date.vnNew(); const date = Date.vnNew();
date.setDate(date.getDate() + 1); Object.assign(controller, {
controller.invoiceDate = date; invoiceDate: date,
controller.maxShipped = date; maxShipped: date,
controller.minInvoicingDate = Date.vnNew(); minInvoicingDate: date,
controller.clientsToInvoice = 'one'; clientsToInvoice: 'one',
controller.clientId = 1101; clientId: 1101,
controller.companyFk = 442; companyFk: 442,
controller.printerFk = 1; printerFk: 1
const response = [{ });
$httpBackend.expectPOST(`InvoiceOuts/clientsToInvoice`).respond([{
clientId: 1101, clientId: 1101,
id: 121 id: 121
}]; }]);
$httpBackend.expect('POST', `InvoiceOuts/clientsToInvoice`).respond(response); $httpBackend.expectPOST(`InvoiceOuts/invoiceClient`).respond();
$httpBackend.expect('POST', `InvoiceOuts/invoiceClient`).respond(1);
controller.makeInvoice(); controller.makeInvoice();
$httpBackend.flush(); $httpBackend.flush();