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

x/unitest/matcher/mod.ts>toContainEntries

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

Use .toContainEntries when checking if an object contains all of the provided entries

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

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

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

Parameters

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