import './index.js';
import watcher from 'core/mocks/watcher';

describe('Claim', () => {
    describe('Component vnClaimBasicData', () => {
        let controller;
        let $scope;

        beforeEach(ngModule('claim'));

        beforeEach(inject(($componentController, $rootScope) => {
            $scope = $rootScope.$new();
            $scope.watcher = watcher;
            const $element = angular.element('<vn-claim-basic-data></vn-claim-basic-data>');
            controller = $componentController('vnClaimBasicData', {$element, $scope});
        }));

        describe('onSubmit()', () => {
            it(`should redirect to 'claim.card.detail' state`, () => {
                jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true);
                jest.spyOn(controller.$state, 'go');
                controller.onSubmit();

                expect(controller.$state.go).toHaveBeenCalledWith('claim.card.detail');
            });
        });
    });
});