Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293/** Tests for caught-value diagnostic text. @module */
import { describe, expect, it,} from '@monochromatic-dev/module-test';
import { caughtValueText, } from '@monochromatic-dev/module-caught-value';
await describe({ name: caughtValueText.name, children: [ it({ name: 'returns Error message text', fn: async () => { /** Error carrying expected message. */ const error = new Error('offline',); expect(caughtValueText(error,),).toBe('offline',); }, },), it({ name: 'preserves primitive thrown value text', fn: async () => { expect(caughtValueText('plain failure',),).toBe('plain failure',); expect(caughtValueText(404,),).toBe('404',); }, },), it({ name: 'preserves caller-defined object text', fn: async () => { /** Number of caller conversion hooks invoked. */ let conversionCount = 0; /** Thrown object carrying diagnostic conversion text. */ const thrownValue = { /** Supplies diagnostic text and records observable invocation. @returns caller-defined diagnostic text. */ toString(): string { conversionCount++; return 'provider details'; }, }; expect(caughtValueText(thrownValue,),).toBe('provider details',); expect(conversionCount,).toBe(1,); }, },), it({ name: 'reads caller-defined Error message getter', fn: async () => { /** Error whose message is supplied by a getter. */ const error = new Error('replaced by getter',); /** Number of message getter invocations. */ let messageReadCount = 0; Object.defineProperty( error, 'message', { configurable: true, /** Supplies diagnostic message and records observable access. @returns getter-provided message. */ get(): string { messageReadCount++; return 'getter details'; }, }, ); expect(caughtValueText(error,),).toBe('getter details',); expect(messageReadCount,).toBe(1,); }, },), ],},);