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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849/** Tests for `booleanOrThrow`. @module */
import { describe, expect, expectTypeOf, it,} from '@monochromatic-dev/module-test/ts';
import { booleanOrThrow, } from '@monochromatic-dev/module-or-throw';
await describe({ name: booleanOrThrow.name, children: [ it({ name: 'returns primitive booleans unchanged', fn: async () => { expect(booleanOrThrow(true,),).toBe(true,); expect(booleanOrThrow(false,),).toBe(false,); }, },),
it({ name: 'throws on truthy/falsy values that are not literal booleans', fn: async () => { expect(() => booleanOrThrow(1,)).toThrow('boolean',); expect(() => booleanOrThrow(0,)).toThrow('boolean',); expect(() => booleanOrThrow('true',)).toThrow('boolean',); expect(() => booleanOrThrow('',)).toThrow('boolean',); expect(() => booleanOrThrow(null,)).toThrow('boolean',); expect(() => booleanOrThrow(undefined,)).toThrow('boolean',); }, },),
it({ name: 'narrows unknown to boolean', fn: async () => { const input: unknown = true; const output = booleanOrThrow(input,); expectTypeOf(output,).toEqualTypeOf<boolean>(); }, },), ],},);