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

39 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2022-05-24 10:50:22 +00:00
import './index';
2022-07-27 11:01:03 +00:00
describe('Shelving', () => {
2022-07-20 11:41:33 +00:00
describe('Component vnShelvingCreate', () => {
2022-07-27 11:01:03 +00:00
let $scope;
let $state;
2022-05-24 10:50:22 +00:00
let controller;
2022-07-20 11:41:33 +00:00
beforeEach(ngModule('shelving'));
2022-05-24 10:50:22 +00:00
2022-07-27 11:01:03 +00:00
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>');
2022-07-20 11:41:33 +00:00
controller = $componentController('vnShelvingCreate', {$element, $scope});
controller.$params = {};
2022-05-24 10:50:22 +00:00
}));
describe('onSubmit()', () => {
2022-07-20 11:41:33 +00:00
it(`should redirect to basic data by calling the $state.go function`, () => {
jest.spyOn(controller.$state, 'go');
2022-05-24 10:50:22 +00:00
2022-07-20 11:41:33 +00:00
controller.onSubmit();
2022-05-24 10:50:22 +00:00
2022-07-27 11:01:03 +00:00
expect(controller.$state.go).toHaveBeenCalledWith('shelving.card.basicData', {id: 1});
2022-05-24 10:50:22 +00:00
});
});
});
});