2018-08-22 10:55:15 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Item', () => {
|
|
|
|
describe('Component vnItemIndex', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
2020-03-17 13:43:46 +00:00
|
|
|
let $scope;
|
2018-08-22 10:55:15 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('item'));
|
2018-08-22 10:55:15 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
2018-08-22 10:55:15 +00:00
|
|
|
$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});
|
2018-08-22 10:55:15 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
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');
|
2018-08-22 10:55:15 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
$httpBackend.expectRoute('POST', `Items/:id/clone`).respond({id: 99});
|
|
|
|
controller.onCloneAccept(1);
|
2018-08-22 10:55:15 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('item.card.tags', {id: 99});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|