fix(supplier_account): fix setWireTransfer and add test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2137a34b36
commit
a27a48f251
|
@ -45,6 +45,16 @@ class Controller extends Section {
|
|||
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', {
|
||||
|
|
|
@ -5,9 +5,12 @@ import crudModel from 'core/mocks/crud-model';
|
|||
describe('Supplier Component vnSupplierAccount', () => {
|
||||
let $scope;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('supplier'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
$scope.model = crudModel;
|
||||
$scope.watcher = watcher;
|
||||
|
@ -66,5 +69,30 @@ describe('Supplier Component vnSupplierAccount', () => {
|
|||
}).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