import './index.js'; describe('Ticket Component vnTicketDescriptor', () => { let $httpBackend; let controller; let $state; const ticket = { id: 2, clientFk: 1101, invoiceOut: {id: 1}, client: { id: 1101, email: 'client@email' }, address: { id: 1101, mobile: 111111111, phone: 2222222222 }, tracking: { state: {alertLevel: 3} } }; beforeEach(ngModule('ticket')); beforeEach(inject(($componentController, _$httpBackend_, _$state_) => { $httpBackend = _$httpBackend_; $state = _$state_; $state.params.id = 1; const $element = angular.element(''); controller = $componentController('vnTicketDescriptor', {$element}); controller.ticket = ticket; })); describe('loadData()', () => { it(`should perform a get query to store the ticket data into the controller`, () => { $httpBackend.expect('GET', `Tickets/${ticket.id}`).respond(); controller.loadData(); $httpBackend.flush(); }); }); describe('transferClient()', () => { it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => { let client = { clientFk: 1101, addressFk: 1, }; $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client); $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond(); controller.transferClient(); $httpBackend.flush(); }); }); });