2018-05-23 12:26:51 +00:00
|
|
|
import './index';
|
2017-08-30 14:05:34 +00:00
|
|
|
|
2017-09-04 13:06:43 +00:00
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientCard', () => {
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2019-11-10 10:08:44 +00:00
|
|
|
let $httpBackend;
|
|
|
|
let data = {id: 1, name: 'fooName'};
|
2017-08-30 14:05:34 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2017-08-30 14:05:34 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => {
|
2019-11-10 10:08:44 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
|
|
|
|
let $element = angular.element('<div></div>');
|
|
|
|
controller = $componentController('vnClientCard', {$element});
|
|
|
|
|
|
|
|
$stateParams.id = data.id;
|
|
|
|
$httpBackend.whenRoute('GET', 'Clients/:id/getCard').respond(data);
|
2017-09-04 13:06:43 +00:00
|
|
|
}));
|
2017-08-30 14:05:34 +00:00
|
|
|
|
2019-11-10 10:08:44 +00:00
|
|
|
it('should request data and set it on the controller', () => {
|
|
|
|
controller.$onInit();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.client).toEqual(data);
|
2017-09-04 13:06:43 +00:00
|
|
|
});
|
2017-08-30 14:05:34 +00:00
|
|
|
});
|
|
|
|
});
|