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

33 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

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