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

x/unitest/matcher/mod.ts>toContainAnyEntries

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

Use .toContainAnyEntries when checking if an object contains at least one of the provided entries

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

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

test("passes when object contains at least one of the given entries", () => {
  const object = { a: "foo", b: "bar", c: "baz" };
  expect(object).toContainAnyEntries([
    ["a", "qux"],
    ["a", "foo"],
  ]);
  expect(object).toContainAnyEntries([
    ["a", "qux"],
    ["b", "bar"],
  ]);
  expect(object).not.toContainAnyEntries([["d", "qux"]]);
});

Parameters

actual: object
expected: [string, unknown][]