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

x/unitest/matcher/to_contain_entry.ts>toContainEntry

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

Use .toContainEntry when checking if an object contains the provided entry

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

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

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

Parameters

actual: object
expected: [PropertyKey, unknown]