import { toSatisfy } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_satisfy.ts";
Use .toSatisfy
when you want to use a custom matcher by supplying a predicate
function that returns a boolean
.
import {
defineExpect,
not,
test,
toSatisfy,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";
const expect = defineExpect({
matcherMap: {
toSatisfy,
},
modifierMap: {
not,
},
});
test("passes when value passes given predicate", () => {
const greaterThanOneButNotThree = (n: unknown) =>
typeof n === "number" && n > 1 && n !== 3;
expect(100).toSatisfy(greaterThanOneButNotThree);
expect(0).not.toSatisfy(greaterThanOneButNotThree);
expect(3).not.toSatisfy(greaterThanOneButNotThree);
});