Skip to main content
Module

x/unitest/mod.ts>toSatisfyAll

🃏 Deno-first universal unit testing framework
Latest
function toSatisfyAll
Re-export
import { toSatisfyAll } from "https://deno.land/x/unitest@v1.0.0-beta.82/mod.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