import { ApiErrorCode } from '@reltio/mdm-sdk';
import { ErrorPopup } from '../../../ErrorPopup';
import { showWorkflowError } from './errors';
describe('errors helpers tests', function () {
    beforeAll(function () {
        jest.spyOn(ErrorPopup, 'addError').mockImplementation(function () { });
    });
    beforeEach(function () {
        jest.clearAllMocks();
    });
    describe('showWorkflowError behavior', function () {
        it('should show workflow error', function () {
            showWorkflowError({
                status: 'failed',
                error: {
                    errorMessage: 'alarm!',
                    errorCode: 123
                }
            });
            expect(ErrorPopup.addError).toHaveBeenCalledWith({
                title: 'Error',
                message: 'alarm!'
            });
        });
        it('should do nothing in case of ApiErrorCode.WORKFLOW_IS_NOT_REGISTERED_ERROR', function () {
            showWorkflowError({
                status: 'failed',
                error: {
                    errorMessage: '',
                    errorCode: ApiErrorCode.WORKFLOW_IS_NOT_REGISTERED_ERROR
                }
            });
            expect(ErrorPopup.addError).not.toHaveBeenCalled();
        });
    });
});
