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

33 lines
1.0 KiB
JavaScript
Raw Normal View History

import './index.js';
describe('Item', () => {
describe('Component vnItemCard', () => {
let controller;
let $httpBackend;
let $state;
let data = {id: 1, name: 'fooName'};
beforeEach(ngModule('item'));
beforeEach(inject(($componentController, _$httpBackend_, $stateParams, _$state_) => {
$httpBackend = _$httpBackend_;
$state = _$state_;
$state.getCurrentPath = () => [null, null, null, null, {state: {name: 'item.card.diary'}}];
let $element = angular.element('<div></div>');
controller = $componentController('vnItemCard', {$element});
$stateParams.id = data.id;
$httpBackend.whenRoute('GET', 'Items/:id/getCard').respond(data);
}));
it('should request data and set it on the controller', () => {
$httpBackend.expect('GET', `ItemConfigs/findOne`).respond({});
controller.reload();
$httpBackend.flush();
expect(controller.item).toEqual(data);
});
});
});