Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.3 KiB
Text
46 lines
1.3 KiB
Text
import { addDays } from "date-fns/addDays";
|
|
|
|
import { DateRange } from "../types";
|
|
|
|
import { rangeIncludesDate } from "./rangeIncludesDate";
|
|
|
|
const date = new Date();
|
|
|
|
describe('when range is missing the "from" date', () => {
|
|
const range: DateRange = { from: undefined };
|
|
const result = rangeIncludesDate(range, date);
|
|
test("should return false", () => {
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('when range is missing the "to" date', () => {
|
|
const result = rangeIncludesDate({ from: date, to: undefined }, date);
|
|
test("should return true", () => {
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("when the range dates are the same as date", () => {
|
|
const range: DateRange = { from: date, to: date };
|
|
const result = rangeIncludesDate(range, date);
|
|
test("should return true", () => {
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("when the range dates are the same but not as date", () => {
|
|
const range: DateRange = { from: date, to: date };
|
|
const result = rangeIncludesDate(range, addDays(date, 1));
|
|
test("should return false", () => {
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("when the range is inverted", () => {
|
|
const range: DateRange = { from: addDays(date, 1), to: date };
|
|
const result = rangeIncludesDate(range, date);
|
|
test("should return true", () => {
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|