Skip to main content
Module

x/unitest/mod.ts>toContainEntry

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