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

29 lines
833 B
JavaScript
Raw Normal View History

import './index.js';
describe('Item', () => {
describe('Component vnItemCard', () => {
let controller;
2019-11-10 10:08:44 +00:00
let $httpBackend;
let data = {id: 1, name: 'fooName'};
beforeEach(ngModule('item'));
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => {
$httpBackend = _$httpBackend_;
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', () => {
controller.reload();
$httpBackend.flush();
2019-11-10 10:08:44 +00:00
expect(controller.item).toEqual(data);
});
});
});