Skip to main content
Module

x/unitest/mod.ts>toBeValidDate

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

Use .toBeValidDate when check that a Date is valid

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

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

test("passes when Date is valid", () => {
  expect(new Date("01/01/2018")).toBeValidDate();
  expect(new Date("01/90/2018")).not.toBeValidDate();
  expect(new Date("invalid")).not.toBeValidDate();
});