0.1.0 • Published 7 months ago

minimal-assertion-helpers v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

minimal-assertion-helpers

provides few test helpers

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

Synopsis

import { describe, 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"
})

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

See also

License

MIT