3671-supplier_account #889
|
@ -45,6 +45,16 @@ class Controller extends Section {
|
||||||
this.$.payMethodToTransfer.show();
|
this.$.payMethodToTransfer.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setWireTransfer() {
|
||||||
|
const params = {
|
||||||
|
id: this.$params.id,
|
||||||
|
payMethodFk: this.wireTransferFk
|
||||||
|
};
|
||||||
|
const query = `Suppliers/${this.$params.id}`;
|
||||||
|
return this.$http.patch(query, params)
|
||||||
|
.then(() => this.$.watcher.notifySaved());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnSupplierAccount', {
|
ngModule.vnComponent('vnSupplierAccount', {
|
||||||
|
|
|
@ -5,9 +5,12 @@ import crudModel from 'core/mocks/crud-model';
|
||||||
describe('Supplier Component vnSupplierAccount', () => {
|
describe('Supplier Component vnSupplierAccount', () => {
|
||||||
let $scope;
|
let $scope;
|
||||||
let controller;
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
|
||||||
beforeEach(ngModule('supplier'));
|
beforeEach(ngModule('supplier'));
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$scope.model = crudModel;
|
$scope.model = crudModel;
|
||||||
$scope.watcher = watcher;
|
$scope.watcher = watcher;
|
||||||
|
@ -66,5 +69,30 @@ describe('Supplier Component vnSupplierAccount', () => {
|
||||||
}).catch(done.fail);
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setWireTransfer()', () => {
|
||||||
|
it(`should make HTTP PATCH request to set wire transfer and call notifySaved`, () => {
|
||||||
|
const supplierId = 1;
|
||||||
|
const params = {
|
||||||
|
id: supplierId,
|
||||||
|
payMethodFk: 2
|
||||||
|
};
|
||||||
|
const response = {
|
||||||
|
data: {id: 2}
|
||||||
|
};
|
||||||
|
const uri = 'payMethods/findOne?filter=%7B%22where%22:%7B%22code%22:%22wireTransfer%22%7D%7D';
|
||||||
|
jest.spyOn($scope.watcher, 'notifySaved');
|
||||||
|
|
||||||
|
controller.$params.id = supplierId;
|
||||||
|
controller.wireTransferFk = 2;
|
||||||
|
controller.supplier = {payMethodFk: 1};
|
||||||
|
$httpBackend.expectGET(uri).respond(response);
|
||||||
|
$httpBackend.expectPATCH(`Suppliers/${supplierId}`, params).respond();
|
||||||
|
controller.setWireTransfer();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue