salix/modules/item/front/index/index.spec.js

31 lines
1.0 KiB
JavaScript
Raw Normal View History

import './index.js';
describe('Item', () => {
describe('Component vnItemIndex', () => {
let controller;
let $httpBackend;
2020-03-17 13:43:46 +00:00
let $scope;
beforeEach(ngModule('item'));
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_;
2020-03-17 13:43:46 +00:00
$scope = $rootScope.$new();
const $element = angular.element('<vn-item-index></vn-item-index>');
controller = $componentController('vnItemIndex', {$element, $scope});
}));
describe('onCloneAccept()', () => {
it('should perform a post query and then call go() then update itemSelected in the controller', () => {
2020-02-26 12:22:52 +00:00
jest.spyOn(controller.$state, 'go');
2020-04-25 09:50:04 +00:00
$httpBackend.expectRoute('POST', `Items/:id/clone`).respond({id: 99});
controller.onCloneAccept(1);
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('item.card.tags', {id: 99});
});
});
});
});