provides few test helpers
This package is implemented with ECMAScript modules. CommonJS is not supported.
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
}
])
})