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 controller;
|
2019-11-10 10:08:44 +00:00
|
|
|
let $httpBackend;
|
|
|
|
let data = {id: 1, name: 'fooName'};
|
2018-02-05 15:53:41 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('item'));
|
2018-02-05 15:53:41 +00:00
|
|
|
|
2019-11-10 10:08:44 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => {
|
2018-02-05 15:53:41 +00:00
|
|
|
$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);
|
2018-02-05 15:53:41 +00:00
|
|
|
}));
|
|
|
|
|
2019-11-10 10:08:44 +00:00
|
|
|
it('should request data and set it on the controller', () => {
|
|
|
|
controller.reload();
|
|
|
|
$httpBackend.flush();
|
2018-09-14 11:43:51 +00:00
|
|
|
|
2019-11-10 10:08:44 +00:00
|
|
|
expect(controller.item).toEqual(data);
|
2018-03-02 09:51:01 +00:00
|
|
|
});
|
2018-02-05 15:53:41 +00:00
|
|
|
});
|
|
|
|
});
|