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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455/** Tests for `nonemptyOrThrow`. @module */
import { describe, expect, it,} from '@monochromatic-dev/module-test/ts';
import { nonemptyOrThrow, } from '@monochromatic-dev/module-or-throw';
await describe({ name: nonemptyOrThrow.name, children: [ it({ name: 'returns the value for every recognized nonempty container', fn: async () => { expect(nonemptyOrThrow('x',),).toBe('x',); const arr = [1,]; expect(nonemptyOrThrow(arr,),).toBe(arr,); const set = new Set([1,],); expect(nonemptyOrThrow(set,),).toBe(set,); const map = new Map([['a', 1,],],); expect(nonemptyOrThrow(map,),).toBe(map,); const obj = { a: 1, }; expect(nonemptyOrThrow(obj,),).toBe(obj,); }, },),
it({ name: 'throws when a recognized container has zero size', fn: async () => { expect(() => nonemptyOrThrow('',)).toThrow('size 0',); expect(() => nonemptyOrThrow([],)).toThrow('size 0',); expect(() => nonemptyOrThrow(new Set(),)).toThrow('size 0',); expect(() => nonemptyOrThrow(new Map(),)).toThrow('size 0',); expect(() => nonemptyOrThrow({},)).toThrow('size 0',); }, },),
it({ name: 'throws when value is not a recognized container', fn: async () => { expect(() => nonemptyOrThrow(null,)).toThrow('sized container',); expect(() => nonemptyOrThrow(undefined,)).toThrow('sized container',); expect(() => nonemptyOrThrow(42,)).toThrow('sized container',); expect(() => nonemptyOrThrow(true,)).toThrow('sized container',); }, },), ],},);