31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Item', () => {
|
|
describe('Component vnItemIndex', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
let $scope;
|
|
|
|
beforeEach(ngModule('item'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
|
|
$httpBackend = _$httpBackend_;
|
|
$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', () => {
|
|
jest.spyOn(controller.$state, 'go');
|
|
|
|
$httpBackend.expectRoute('POST', `Items/:id/clone`).respond({id: 99});
|
|
controller.onCloneAccept(1);
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('item.card.tags', {id: 99});
|
|
});
|
|
});
|
|
});
|
|
});
|