import { toSatisfyAny } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_satisfy_any.ts";
Use .toSatisfyAny
when you want to use a custom matcher by supplying a
predicate function that returns true
for any matching value in an array
import {
defineExpect,
not,
test,
toSatisfyAny,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";
const expect = defineExpect({
matcherMap: {
toSatisfyAny,
},
modifierMap: {
not,
},
});
test("passes when any value in array pass given predicate", () => {
const isOdd = (el: unknown) => typeof el === "number" && el % 2 === 1;
expect([2, 3, 6, 8]).toSatisfyAny(isOdd);
expect([2, 4, 8, 12]).not.toSatisfyAny(isOdd);
});