@getclave/lifi-sdk
Version:
LI.FI Any-to-Any Cross-Chain-Swap SDK
26 lines (25 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const SDKError_1 = require("../SDKError");
const baseError_1 = require("../baseError");
const constants_1 = require("../constants");
const rootCause_1 = require("./rootCause");
const getErrorChain = () => {
const NonLiFiErrorChain = new Error('non lifi error');
NonLiFiErrorChain.cause = new Error('root cause');
return new SDKError_1.SDKError(new baseError_1.BaseError(constants_1.ErrorName.ValidationError, constants_1.LiFiErrorCode.ValidationError, 'something happened', NonLiFiErrorChain));
};
(0, vitest_1.describe)('getRootCause', () => {
(0, vitest_1.it)('should return the top level error when there is no root cause', () => {
const error = new Error('top level');
(0, vitest_1.expect)((0, rootCause_1.getRootCause)(error).message).toEqual('top level');
});
(0, vitest_1.it)('should return the root cause', () => {
const errorChain = getErrorChain();
(0, vitest_1.expect)((0, rootCause_1.getRootCause)(errorChain).message).toEqual('root cause');
});
(0, vitest_1.it)('should return undefined when passed undefined', () => {
(0, vitest_1.expect)((0, rootCause_1.getRootCause)(undefined)).toBeUndefined();
});
});