/** * Assertions module. * * Provides a collection of assertion functions for testing and validation. * Assertions throw on failure, making them suitable for use in test suites. * * ```js * import assert from 'tjs:assert'; * * assert.eq(1 + 1, 2, 'math works'); * assert.ok(true, 'is truthy'); * assert.throws(() => { throw new Error('boom'); }, /boom/); * ``` * * @module tjs:assert */ declare module 'tjs:assert'{ export interface IAssertionResult { pass: boolean; actual: unknown; expected: T; description: string; operator: string; at?: string; } export interface ComparatorAssertionFunction { (actual: unknown, expected: T, description?: string): IAssertionResult; } export interface BooleanAssertionFunction { (actual: unknown, description?: string): IAssertionResult; } export type ErrorAssertionFunction = { ( fn: Function, expected: RegExp | Function, description?: string ): IAssertionResult; (fn: Function, description?: string): IAssertionResult; }; export interface MessageAssertionFunction { (message?: string): IAssertionResult; } export interface IAssert { equal: ComparatorAssertionFunction; equals: ComparatorAssertionFunction; eq: ComparatorAssertionFunction; deepEqual: ComparatorAssertionFunction; notEqual: ComparatorAssertionFunction; notEquals: ComparatorAssertionFunction; notEq: ComparatorAssertionFunction; notDeepEqual: ComparatorAssertionFunction; is: ComparatorAssertionFunction; same: ComparatorAssertionFunction; isNot: ComparatorAssertionFunction; notSame: ComparatorAssertionFunction; ok: BooleanAssertionFunction; truthy: BooleanAssertionFunction; notOk: BooleanAssertionFunction; falsy: BooleanAssertionFunction; fail: MessageAssertionFunction; throws: ErrorAssertionFunction; doesNotThrow: ErrorAssertionFunction; } function factory(options?: IAssertOptions): IAssert; export const Assert: IAssert; export interface IAssertOptions { onResult: (result: IAssertionResult) => void; } export default Assert; }