salix/modules/shelving/front/create/index.spec.js

39 lines
1.2 KiB
JavaScript

import './index';
describe('Shelving', () => {
describe('Component vnShelvingCreate', () => {
let $scope;
let $state;
let controller;
beforeEach(ngModule('shelving'));
beforeEach(inject(($componentController, $rootScope, _$state_) => {
$scope = $rootScope.$new();
$state = _$state_;
$scope.watcher = {
submit: () => {
return {
then: callback => {
callback({data: {id: 1}});
}
};
}
};
const $element = angular.element('<vn-shelving-create></vn-shelving-create>');
controller = $componentController('vnShelvingCreate', {$element, $scope});
controller.$params = {};
}));
describe('onSubmit()', () => {
it(`should redirect to basic data by calling the $state.go function`, () => {
jest.spyOn(controller.$state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1});
});
});
});
});