2018-05-25 08:03:45 +00:00
|
|
|
import './index.js';
|
2018-02-05 15:53:41 +00:00
|
|
|
|
|
|
|
describe('Item', () => {
|
|
|
|
describe('Component vnItemCard', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $httpBackend;
|
2018-09-14 11:43:51 +00:00
|
|
|
let $stateParams;
|
2018-02-05 15:53:41 +00:00
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('item');
|
|
|
|
});
|
|
|
|
|
2018-09-14 11:43:51 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, _$stateParams_, _$httpBackend_) => {
|
2018-02-05 15:53:41 +00:00
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
2018-05-25 15:25:35 +00:00
|
|
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
2018-09-14 11:43:51 +00:00
|
|
|
$stateParams = {
|
|
|
|
id: 123
|
2018-02-20 13:30:02 +00:00
|
|
|
};
|
2018-09-14 11:43:51 +00:00
|
|
|
controller = $componentController('vnItemCard', {$stateParams});
|
2018-02-05 15:53:41 +00:00
|
|
|
}));
|
|
|
|
|
2018-09-14 11:43:51 +00:00
|
|
|
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();
|
2018-03-02 09:51:01 +00:00
|
|
|
$httpBackend.flush();
|
2018-09-14 11:43:51 +00:00
|
|
|
|
|
|
|
expect(controller.item).toEqual(response);
|
2018-03-02 09:51:01 +00:00
|
|
|
});
|
|
|
|
});
|
2018-02-05 15:53:41 +00:00
|
|
|
});
|
|
|
|
});
|