import './index'; describe('Ticket', () => { describe('Component vnTicketCard', () => { let controller; let $httpBackend; let data = { id: 1, client: {name: 'fooName'} }; let client = {debt: 10.5}; beforeEach(ngModule('ticket')); beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; let $element = angular.element('
'); controller = $componentController('vnTicketCard', {$element}); $stateParams.id = data.id; $httpBackend.whenRoute('GET', 'Tickets/:id').respond(data); $httpBackend.whenRoute('GET', 'Clients/:id/getDebt').respond(client); })); it('should request data and set it on the controller', () => { controller.reload(); $httpBackend.flush(); expect(controller.ticket).toMatchObject(data); }); }); });