2018-11-08 14:20:42 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2019-11-25 06:46:00 +00:00
|
|
|
describe('Ticket Component vnTicketDescriptor', () => {
|
2018-11-08 14:20:42 +00:00
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
2019-09-06 07:47:58 +00:00
|
|
|
let $state;
|
2018-11-08 14:20:42 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
const ticket = {
|
|
|
|
id: 2,
|
2021-06-23 11:24:23 +00:00
|
|
|
clientFk: 1101,
|
2020-04-30 10:48:52 +00:00
|
|
|
invoiceOut: {id: 1},
|
|
|
|
client: {
|
2021-06-23 11:24:23 +00:00
|
|
|
id: 1101,
|
2020-04-30 10:48:52 +00:00
|
|
|
email: 'client@email'
|
|
|
|
},
|
|
|
|
address: {
|
2021-06-23 11:24:23 +00:00
|
|
|
id: 1101,
|
2020-04-30 10:48:52 +00:00
|
|
|
mobile: 111111111,
|
|
|
|
phone: 2222222222
|
|
|
|
},
|
|
|
|
tracking: {
|
|
|
|
state: {alertLevel: 3}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('ticket'));
|
2018-11-08 14:20:42 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, _$state_) => {
|
2018-11-08 14:20:42 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-04-30 10:48:52 +00:00
|
|
|
$state = _$state_;
|
2020-06-17 07:49:14 +00:00
|
|
|
$state.params.id = 1;
|
2018-11-08 14:20:42 +00:00
|
|
|
|
2020-11-10 09:38:25 +00:00
|
|
|
const $element = angular.element('<vn-ticket-descriptor></vn-ticket-descriptor>');
|
|
|
|
controller = $componentController('vnTicketDescriptor', {$element});
|
|
|
|
controller.ticket = ticket;
|
2020-04-30 10:48:52 +00:00
|
|
|
}));
|
2018-11-08 14:20:42 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
describe('loadData()', () => {
|
|
|
|
it(`should perform a get query to store the ticket data into the controller`, () => {
|
2020-11-10 09:38:25 +00:00
|
|
|
$httpBackend.expect('GET', `Tickets/${ticket.id}`).respond();
|
2020-09-02 11:09:30 +00:00
|
|
|
controller.loadData();
|
2020-04-30 10:48:52 +00:00
|
|
|
$httpBackend.flush();
|
2020-03-11 07:45:54 +00:00
|
|
|
});
|
|
|
|
});
|
2022-10-25 07:23:46 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
2018-11-08 14:20:42 +00:00
|
|
|
});
|