"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../../types");
const PolymeshError_1 = require("../PolymeshError");
describe('Polymesh Error class', () => {
    test('should extend error', () => {
        expect(PolymeshError_1.PolymeshError.prototype instanceof Error).toBe(true);
    });
    describe('constructor', () => {
        test('should assign code and message to instance', () => {
            const code = types_1.ErrorCode.FatalError;
            const message = 'Everything has gone to hell';
            const err = new PolymeshError_1.PolymeshError({ code, message });
            expect(err.code).toBe(code);
            expect(err.message).toBe(message);
        });
        test('should assign a default message if none is given', () => {
            const code = types_1.ErrorCode.FatalError;
            const err = new PolymeshError_1.PolymeshError({ code });
            expect(err.code).toBe(code);
            expect(err.message).toBe(`Unknown error, code: ${code}`);
        });
    });
});
describe('isPolymeshError', () => {
    test('should return whether the input is a PolymeshError object', () => {
        let result = PolymeshError_1.isPolymeshError(new PolymeshError_1.PolymeshError({ code: types_1.ErrorCode.FatalError }));
        expect(result).toBe(true);
        result = PolymeshError_1.isPolymeshError('Hello');
        expect(result).toBe(false);
    });
});
//# sourceMappingURL=PolymeshError.js.map