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('<vn-ticket-descriptor></vn-ticket-descriptor>');
        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();
        });
    });
});