import './index';

describe('Ticket', () => {
    describe('Component vnTicketExpedition', () => {
        let controller;
        let $scope;
        let $httpBackend;

        beforeEach(ngModule('ticket'));

        beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
            $httpBackend = _$httpBackend_;
            $scope = $rootScope.$new();
            $scope.model = {
                refresh: () => {}
            };
            controller = $componentController('vnTicketExpedition', {$element: null, $scope});
        }));

        describe('onDialogAccept()', () => {
            it('should perform a DELETE query', () => {
                jest.spyOn($scope.model, 'refresh');

                const id = 1;

                $httpBackend.expectDELETE(`Expeditions/${id}`).respond(200);
                controller.onDialogAccept(id);
                $httpBackend.flush();

                expect($scope.model.refresh).toHaveBeenCalledWith();
            });
        });
    });
});