test front ok
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
bc34be85ef
commit
2fe4fad28a
|
@ -10,13 +10,13 @@ describe('InvoiceIn', () => {
|
||||||
|
|
||||||
beforeEach(ngModule('invoiceIn'));
|
beforeEach(ngModule('invoiceIn'));
|
||||||
|
|
||||||
beforeEach(inject(($componentController, _$httpBackend_, $rootScope, _vnApp_) => {
|
beforeEach(inject(($componentController, $rootScope, _vnApp_) => {
|
||||||
vnApp = _vnApp_;
|
vnApp = _vnApp_;
|
||||||
jest.spyOn(vnApp, 'showError');
|
jest.spyOn(vnApp, 'showError');
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$scope.model = crudModel;
|
$scope.model = crudModel;
|
||||||
|
|
||||||
$scope.watcher = watcher;
|
$scope.watcher = watcher;
|
||||||
|
|
||||||
const $element = angular.element('<vn-invoice-in-tax></vn-invoice-in-tax>');
|
const $element = angular.element('<vn-invoice-in-tax></vn-invoice-in-tax>');
|
||||||
controller = $componentController('vnInvoiceInTax', {$element, $scope});
|
controller = $componentController('vnInvoiceInTax', {$element, $scope});
|
||||||
controller.invoiceIn = {id: 1};
|
controller.invoiceIn = {id: 1};
|
||||||
|
|
|
@ -39,13 +39,7 @@ class Controller extends Section {
|
||||||
this.$.bankEntity.open();
|
this.$.bankEntity.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
onBankEntityAccept() {
|
setWireTransfer() {
|
||||||
const query = `SupplierAccounts/${this.$params.id}/createBankEntity`;
|
|
||||||
return this.$http.patch(query, this.newBankEntity)
|
|
||||||
.then(res => this.supplierAccount.bankEntityFk = res.data.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
onAddSave() {
|
|
||||||
const values = {
|
const values = {
|
||||||
id: this.$params.id,
|
id: this.$params.id,
|
||||||
payMethodFk: this.wireTransferFk
|
payMethodFk: this.wireTransferFk
|
||||||
|
@ -57,7 +51,7 @@ class Controller extends Section {
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.$.watcher.check();
|
this.$.watcher.check();
|
||||||
this.$.model.save()
|
return this.$.model.save()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$.watcher.notifySaved();
|
this.$.watcher.notifySaved();
|
||||||
this.$.watcher.updateOriginalData();
|
this.$.watcher.updateOriginalData();
|
||||||
|
|
|
@ -1,23 +1,32 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
describe('Supplier Component vnSupplierAccount', () => {
|
describe('Supplier Component vnSupplierAccount', () => {
|
||||||
let $scope;
|
let $scope;
|
||||||
let $element;
|
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
let $httpParamSerializer;
|
let $httpParamSerializer;
|
||||||
|
let vnApp;
|
||||||
|
|
||||||
beforeEach(ngModule('supplier'));
|
beforeEach(ngModule('supplier'));
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_, _vnApp_) => {
|
||||||
|
vnApp = _vnApp_;
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$httpParamSerializer = _$httpParamSerializer_;
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
|
jest.spyOn(vnApp, 'showError');
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
|
$scope.model = crudModel;
|
||||||
|
$scope.watcher = watcher;
|
||||||
|
|
||||||
$scope.bankEntity = {
|
$scope.bankEntity = {
|
||||||
open: () => {}
|
open: () => {}
|
||||||
};
|
};
|
||||||
$httpBackend.whenRoute('GET', 'PayMethods')
|
$httpBackend.whenRoute('GET', 'PayMethods')
|
||||||
.respond([{id: 1}]);
|
.respond([{id: 1}]);
|
||||||
$element = angular.element('<vn-supplier-accounts></supplier-accounts>');
|
|
||||||
|
const $element = angular.element('<vn-supplier-account></vn-supplier-account>');
|
||||||
controller = $componentController('vnSupplierAccount', {$element, $scope});
|
controller = $componentController('vnSupplierAccount', {$element, $scope});
|
||||||
controller.supplierAccount = {
|
controller.supplierAccount = {
|
||||||
supplierFk: 442,
|
supplierFk: 442,
|
||||||
|
@ -79,5 +88,52 @@ describe('Supplier Component vnSupplierAccount', () => {
|
||||||
expect(controller.supplierAccount.bankEntityFk).toEqual(controller.bankEntity.id);
|
expect(controller.supplierAccount.bankEntityFk).toEqual(controller.bankEntity.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('onSubmit__()', () => {
|
||||||
|
it(`should reload the card`, () => {
|
||||||
|
controller.card = {reload: () => {}};
|
||||||
|
jest.spyOn($scope.watcher, 'check');
|
||||||
|
jest.spyOn($scope.watcher, 'notifySaved');
|
||||||
|
jest.spyOn($scope.watcher, 'updateOriginalData');
|
||||||
|
jest.spyOn(controller.card, 'reload');
|
||||||
|
jest.spyOn($scope.model, 'save');
|
||||||
|
console.log($scope.model);
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect($scope.model.save).toHaveBeenCalledWith();
|
||||||
|
expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||||
|
expect($scope.watcher.check).toHaveBeenCalledWith();
|
||||||
|
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||||
|
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||||
|
|
||||||
|
expect(controller.$.payMethodToTransfer.show).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
fdescribe('onSubmit()', () => {
|
||||||
|
it(`should reload the card`, done => {
|
||||||
|
controller.card = {reload: () => {}};
|
||||||
|
controller.$.payMethodToTransfer = {show: () => {}};
|
||||||
|
jest.spyOn(controller.$.payMethodToTransfer, 'show');
|
||||||
|
jest.spyOn(controller.$.model, 'save').mockReturnValue(new Promise(resolve => {
|
||||||
|
return resolve({
|
||||||
|
id: 1234
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
jest.spyOn(controller.card, 'reload').mockReturnValue(new Promise(resolve => {
|
||||||
|
return resolve({
|
||||||
|
id: 1234
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
controller.wireTransferFk = 'a';
|
||||||
|
controller.supplier = {payMethodFk: 'b'};
|
||||||
|
controller.onSubmit().then(() => {
|
||||||
|
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||||
|
expect(controller.$.payMethodToTransfer.show).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
}).catch(done.fail);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue