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

x/unitest/matcher/to_be_between.ts>toBeBetween

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

Use .toBeBetween when checking if a date equals or occurs after startDate and equals or occurs before endDate

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

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

test("passes when input is in given date range", () => {
  expect(new Date("05/01/2019")).toBeBetween(
    new Date("01/01/2019"),
    new Date("10/01/2019"),
  );
  expect(new Date("05/01/2019")).toBeBetween(
    new Date("05/01/2019"),
    new Date("10/01/2019"),
  );
  expect(new Date("01/01/2019")).not.toBeBetween(
    new Date("05/01/2019"),
    new Date("10/01/2019"),
  );
});

Parameters

actual: Date
startDate: Date
endDate: Date