salix/client/item/src/card/index.spec.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

import './index.js';
describe('Item', () => {
describe('Component vnItemCard', () => {
let $componentController;
let $httpBackend;
let $stateParams;
let controller;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, _$stateParams_, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$stateParams = {
id: 123
2018-02-20 13:30:02 +00:00
};
controller = $componentController('vnItemCard', {$stateParams});
}));
describe('getCard()', () => {
it('should request to set the item into the controller', () => {
let response = {id: 123};
$httpBackend.when('GET', `/item/api/Items/123/getCard`).respond(response);
$httpBackend.expect('GET', `/item/api/Items/123/getCard`);
controller.getCard();
$httpBackend.flush();
expect(controller.item).toEqual(response);
});
});
});
});