salix/modules/supplier/front/address/edit/index.spec.js

40 lines
1.3 KiB
JavaScript
Raw Normal View History

import './index';
import watcher from 'core/mocks/watcher';
describe('Supplier', () => {
describe('Component vnSupplierAddressEdit', () => {
let $scope;
let controller;
let $element;
let $state;
beforeEach(ngModule('supplier'));
beforeEach(inject(($componentController, $rootScope, _$state_) => {
$scope = $rootScope.$new();
$state = _$state_;
$state.params.addressId = '1';
$element = angular.element('<vn-supplier-address-edit></vn-supplier-address-edit>');
controller = $componentController('vnSupplierAddressEdit', {$element, $scope});
controller.address = {id: 1};
controller.$.watcher = watcher;
controller.$.watcher.submit = () => {
return {
then: callback => {
callback({data: {id: 124}});
}
};
};
}));
describe('onSubmit()', () => {
it('should perform a PATCH and then redirect to the main section', () => {
jest.spyOn(controller.$state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index');
});
});
});
});