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;
|
2023-02-21 11:17:16 +00:00
|
|
|
let $state;
|
2019-11-10 10:08:44 +00:00
|
|
|
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
|
|
|
|
2023-02-21 11:17:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $stateParams, _$state_) => {
|
2018-02-05 15:53:41 +00:00
|
|
|
$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);
|
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', () => {
|
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();
|
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
|
|
|
});
|
|
|
|
});
|