refs #5000 Invoicing: front tests refactor & fixes
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
4cc6485cbd
commit
7f60335a91
|
@ -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`);
|
||||
|
||||
|
|
|
@ -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('<vn-invoice-out-global-invoicing></vn-invoice-out-global-invoicing>');
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue