import { ErrorPopup } from '../ErrorPopup';
import { showErrorMessage, showDefaultErrorMessage } from './errors';
describe('showErrorMessage tests', function () {
    beforeAll(function () {
        jest.spyOn(ErrorPopup, 'addError').mockImplementation(function () { });
    });
    beforeEach(function () {
        jest.clearAllMocks();
    });
    it('should show ErrorPopup with correct props', function () {
        showErrorMessage({
            errorMessage: 'Error message',
            errorCode: 123
        });
        expect(ErrorPopup.addError).toHaveBeenCalledWith({
            title: 'Error',
            message: 'Error message'
        });
    });
    it('should show custom default message if errorMessage is not provided', function () {
        showErrorMessage({
            errorMessage: '',
            errorCode: 123
        }, { defaultMessage: 'Custom message' });
        expect(ErrorPopup.addError).toHaveBeenCalledWith({
            title: 'Error',
            message: 'Custom message'
        });
    });
    it('should show custom message if it is provided', function () {
        showErrorMessage({
            errorMessage: 'Error message',
            errorCode: 123
        }, { message: 'Custom message' });
        expect(ErrorPopup.addError).toHaveBeenCalledWith({
            title: 'Error',
            message: 'Custom message'
        });
    });
    it('should show custom title if it is provided', function () {
        showErrorMessage({
            errorMessage: 'Error message',
            errorCode: 123
        }, { title: 'Custom title' });
        expect(ErrorPopup.addError).toHaveBeenCalledWith({
            title: 'Custom title',
            message: 'Error message'
        });
    });
    describe('showDefaultErrorMessage tests', function () {
        it('should show default message if errorMessage is not provided', function () {
            showDefaultErrorMessage({
                errorMessage: '',
                errorCode: 123
            });
            expect(ErrorPopup.addError).toHaveBeenCalledWith({
                title: 'Error',
                message: 'Something went wrong'
            });
        });
    });
});
