Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/unitest/matcher/to_satisfy_all.ts>toSatisfyAll

๐Ÿƒ Deno-first universal unit testing framework
Latest
function toSatisfyAll
import { toSatisfyAll } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_satisfy_all.ts";

Use .toSatisfyAll when you want to use a custom matcher by supplying a predicate function that returns a boolean for all values in an array

import {
  defineExpect,
  not,
  test,
  toSatisfyAll,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";

const expect = defineExpect({
  matcherMap: {
    toSatisfyAll,
  },
  modifierMap: {
    not,
  },
});

test("passes when all values in array pass given predicate", () => {
  const isOdd = (el: unknown) => typeof el === "number" && el % 2 === 1;
  expect([1, 3, 5, 7]).toSatisfyAll(isOdd);
  expect([1, 3, 4, 5, 7]).not.toSatisfyAll(isOdd);
});

Parameters

actual: T[]
predicate: (value: T) => boolean