import { DateObjectUnits, MakeOptionalRequired, TimeMeridiem } from '../types'; /** * Test Utilities for @rnwonder/simple-datejs * Provides common helpers for date objects, DOM mocking, and assertions */ /** * Creates a standardized date object for testing */ export declare const createTestDateObject: (day: number, month: number, year: number) => MakeOptionalRequired; /** * Creates a Date object from test parameters with timezone handling */ export declare const createTestDate: (year: number, month: number, day: number) => Date; /** * Creates a mock date with specific time for testing time-dependent functions */ export declare const createMockDateTime: (year: number, month: number, day: number, hour?: number, minute?: number, second?: number) => Date; /** * Compares two date objects for equality in tests */ export declare const expectDateObjectsEqual: (actual: DateObjectUnits, expected: DateObjectUnits) => void; /** * Validates that a date object has all required properties */ export declare const expectValidDateObject: (dateObj: DateObjectUnits) => void; /** * Creates a mock DOM element with configurable getBoundingClientRect * Uses real DOM element in jsdom environment for better compatibility */ export declare const createMockElement: (rect?: Partial) => HTMLElement; /** * Creates a mock window object with configurable dimensions */ export declare const createMockWindow: (innerWidth?: number, innerHeight?: number) => { innerWidth: number; innerHeight: number; outerWidth: number; outerHeight: number; scrollX: number; scrollY: number; addEventListener: import('vitest').Mock; removeEventListener: import('vitest').Mock; }; /** * Creates a mock document object for DOM testing * In jsdom environment, we can use the real document object */ export declare const createMockDocument: () => Document; /** * Sets up DOM mocks for portal positioning tests * In jsdom environment, we enhance the existing window and document objects */ export declare const setupPortalMocks: (elementRect?: Partial, windowDimensions?: { width: number; height: number; }) => { mockElement: HTMLElement; mockWindow: Window & typeof globalThis; mockDocument: Document; }; /** * Sets up fake timers with a specific date */ export declare const setupMockTime: (date?: Date | string) => void; /** * Restores real timers */ export declare const restoreTime: () => void; /** * Creates a mock Date constructor that returns a specific date */ export declare const mockDateConstructor: (mockDate: Date) => () => void; /** * Common test dates for various scenarios */ export declare const TEST_DATES: { readonly STANDARD: MakeOptionalRequired; readonly NEW_YEAR: MakeOptionalRequired; readonly LEAP_YEAR: MakeOptionalRequired; readonly MONTH_END: MakeOptionalRequired; readonly MONTH_START: MakeOptionalRequired; readonly PAST: MakeOptionalRequired; readonly FUTURE: MakeOptionalRequired; readonly YEAR_2000: MakeOptionalRequired; readonly YEAR_1999: MakeOptionalRequired; readonly CENTURY_START: MakeOptionalRequired; readonly CENTURY_END: MakeOptionalRequired; }; /** * Test locales for internationalization testing */ export declare const TEST_LOCALES: readonly ["en-US", "en-GB", "es-MX", "fr-FR", "de-DE", "ja-JP", "zh-CN", "ar-SA", "hi-IN", "pt-BR"]; /** * Test scenarios for time conversion */ export declare const TIME_CONVERSION_SCENARIOS: readonly [{ readonly hour24: 0; readonly expected12: { readonly hour: 12; readonly meridiem: TimeMeridiem; }; }, { readonly hour24: 1; readonly expected12: { readonly hour: 1; readonly meridiem: TimeMeridiem; }; }, { readonly hour24: 11; readonly expected12: { readonly hour: 11; readonly meridiem: TimeMeridiem; }; }, { readonly hour24: 12; readonly expected12: { readonly hour: 12; readonly meridiem: TimeMeridiem; }; }, { readonly hour24: 13; readonly expected12: { readonly hour: 1; readonly meridiem: TimeMeridiem; }; }, { readonly hour24: 23; readonly expected12: { readonly hour: 11; readonly meridiem: TimeMeridiem; }; }]; /** * Test scenarios for date ranges */ export declare const DATE_RANGE_SCENARIOS: readonly [{ readonly name: "same_month_range"; readonly start: MakeOptionalRequired; readonly end: MakeOptionalRequired; }, { readonly name: "cross_month_range"; readonly start: MakeOptionalRequired; readonly end: MakeOptionalRequired; }, { readonly name: "cross_year_range"; readonly start: MakeOptionalRequired; readonly end: MakeOptionalRequired; }, { readonly name: "single_day_range"; readonly start: MakeOptionalRequired; readonly end: MakeOptionalRequired; }]; /** * Test data for DOM positioning scenarios */ export declare const POSITIONING_SCENARIOS: readonly [{ readonly name: "top_left"; readonly elementRect: { readonly top: 100; readonly left: 100; readonly width: 200; readonly height: 30; }; readonly windowSize: { readonly width: 1024; readonly height: 768; }; }, { readonly name: "bottom_right"; readonly elementRect: { readonly top: 600; readonly left: 800; readonly width: 200; readonly height: 30; }; readonly windowSize: { readonly width: 1024; readonly height: 768; }; }, { readonly name: "center"; readonly elementRect: { readonly top: 350; readonly left: 400; readonly width: 200; readonly height: 30; }; readonly windowSize: { readonly width: 1024; readonly height: 768; }; }, { readonly name: "small_screen"; readonly elementRect: { readonly top: 200; readonly left: 150; readonly width: 200; readonly height: 30; }; readonly windowSize: { readonly width: 480; readonly height: 800; }; }]; /** * Test data for year ranges */ export declare const YEAR_RANGE_SCENARIOS: readonly [{ readonly start: 2020; readonly end: 2025; readonly count: 6; }, { readonly start: 1990; readonly end: 2030; readonly count: 41; }, { readonly start: 2023; readonly end: 2023; readonly count: 1; }, { readonly start: 2000; readonly end: 2010; readonly count: 11; }]; /** * Asserts that a value is a valid date object */ export declare const assertValidDateObject: (value: any) => asserts value is DateObjectUnits; /** * Asserts that a value is a valid JavaScript Date */ export declare const assertValidJSDate: (value: any) => asserts value is Date; /** * Asserts that a date range is valid */ export declare const assertValidDateRange: (start: any, end: any) => void; /** * Asserts that a positioning result has required properties */ export declare const assertValidPositioning: (position: any) => void; /** * Sets up a clean test environment with all necessary mocks */ export declare const setupTestEnvironment: () => () => void; /** * Creates a test suite wrapper with common setup and teardown */ export declare const createTestSuite: (name: string, tests: () => void) => void; /** * Measures execution time of a function */ export declare const measureExecutionTime: (fn: () => void | Promise) => Promise; /** * Asserts that a function executes within a time limit */ export declare const expectExecutionTime: (fn: () => void | Promise, maxTime: number) => Promise; export * from '../types';