UNPKG

glitchkit

Version:

A lightweight toolkit to create and manage expressive, structured, and reusable error types. Perfect for APIs, services, and glitchy adventures

35 lines (34 loc) 1.81 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const GlitchKitBaseError_1 = __importDefault(require("../../baseGlitchKit/GlitchKitBaseError")); const GlitchKitBusinessLogicError_1 = __importDefault(require("../GlitchKitBusinessLogicError")); describe('GlitchKitBusinessLogicError', () => { it('should be instance of GlitchKitBusinessLogicError and GlitchKitBaseError', () => { const err = new GlitchKitBusinessLogicError_1.default('Business logic failed', 1001); expect(err).toBeInstanceOf(GlitchKitBusinessLogicError_1.default); expect(err).toBeInstanceOf(GlitchKitBaseError_1.default); expect(err).toBeInstanceOf(Error); }); it('should set message and errorCode correctly', () => { const err = new GlitchKitBusinessLogicError_1.default('Some error', 42); expect(err.message).toBe('Some error'); expect(err.errorCode).toBe(42); }); it('should set prototype correctly', () => { const err = new GlitchKitBusinessLogicError_1.default('Proto test'); expect(Object.getPrototypeOf(err)).toBe(GlitchKitBusinessLogicError_1.default.prototype); }); it('should capture stack trace', () => { const err = new GlitchKitBusinessLogicError_1.default('Stack trace test'); expect(err.stack).toContain('GlitchKitBusinessLogicError'); }); describe('isInstance', () => { it('should return true for GlitchKitBusinessLogicError instance', () => { const err = new GlitchKitBusinessLogicError_1.default('Test'); expect(GlitchKitBusinessLogicError_1.default.isInstance(err)).toBe(true); }); }); });