Skip to content

fibo/minimal-assertion-helpers

Repository files navigation

minimal-assertion-helpers

provides few test helpers

This package is implemented with ECMAScript modules. CommonJS is not supported.

Synopsis

import { test } from "node:test"
import { MaybeObject, objectTypeGuard } from "minimal-type-guard-helpers"
import { assertEqual } from "minimal-assertion-helpers"

type Foo = { bar: string }

const isFoo = objectTypeGuard<Foo>(({ bar }) => {
  return typeof bar === "string"
})

test("isFoo", () => {
  assertEqual<MaybeObject<Foo>, boolean>(isFoo, [
    {
      input: {
        foo: "string"
      },
      output: true
    },
    {
      input: {
        foo: 42
      },
      output: false
    },
    {
      input: {},
      output: false
    }
  ])
})

See also

License

MIT

Releases

No releases published

Packages

No packages published