WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...
    • Enhanced helper to mock date for consistent testing with edge case handling Provides comprehensive date mocking capabilities for various testing scenarios

      Parameters

      • date: Date = ...

      Returns {
          restore: () => void;
          setDate: (newDate: Date) => void;
          advanceBy: (milliseconds: number) => void;
          advanceByDays: (days: number) => void;
          advanceByHours: (hours: number) => void;
          advanceByMinutes: (minutes: number) => void;
          getCurrentDate: () => Date;
          reset: () => void;
          mockTimezone: (timezoneOffset: number) => { restore: () => void };
          createRelativeDate: (offset: number) => Date;
          helpers: {
              yesterday: () => Date;
              tomorrow: () => Date;
              oneWeekAgo: () => Date;
              oneWeekFromNow: () => Date;
              oneMonthAgo: () => Date;
              oneMonthFromNow: () => Date;
              oneYearAgo: () => Date;
              oneYearFromNow: () => Date;
              startOfDay: () => Date;
              endOfDay: () => Date;
              startOfWeek: () => Date;
              endOfWeek: () => Date;
              startOfMonth: () => Date;
              endOfMonth: () => Date;
              startOfYear: () => Date;
              endOfYear: () => Date;
              expiredDate: () => Date;
              futureDate: () => Date;
              isoString: () => string;
              unixTimestamp: () => number;
              jwtExpiration: () => number;
              jwtIssuedAt: () => number;
          };
      }

      • restore: () => void

        Restore the original Date constructor

      • setDate: (newDate: Date) => void

        Update the mocked date to a new value

      • advanceBy: (milliseconds: number) => void

        Advance the mocked date by a specified amount

      • advanceByDays: (days: number) => void

        Advance the mocked date by a specified number of days

      • advanceByHours: (hours: number) => void

        Advance the mocked date by a specified number of hours

      • advanceByMinutes: (minutes: number) => void

        Advance the mocked date by a specified number of minutes

      • getCurrentDate: () => Date

        Get the current mocked date

      • reset: () => void

        Reset to the original mocked date

      • mockTimezone: (timezoneOffset: number) => { restore: () => void }

        Mock a specific timezone by adjusting the date

      • createRelativeDate: (offset: number) => Date

        Create a date that's relative to the current mocked date

      • helpers: {
            yesterday: () => Date;
            tomorrow: () => Date;
            oneWeekAgo: () => Date;
            oneWeekFromNow: () => Date;
            oneMonthAgo: () => Date;
            oneMonthFromNow: () => Date;
            oneYearAgo: () => Date;
            oneYearFromNow: () => Date;
            startOfDay: () => Date;
            endOfDay: () => Date;
            startOfWeek: () => Date;
            endOfWeek: () => Date;
            startOfMonth: () => Date;
            endOfMonth: () => Date;
            startOfYear: () => Date;
            endOfYear: () => Date;
            expiredDate: () => Date;
            futureDate: () => Date;
            isoString: () => string;
            unixTimestamp: () => number;
            jwtExpiration: () => number;
            jwtIssuedAt: () => number;
        }

        Helper methods for common date testing scenarios

        • yesterday: () => Date

          Get a date representing "yesterday" relative to the mocked date

        • tomorrow: () => Date

          Get a date representing "tomorrow" relative to the mocked date

        • oneWeekAgo: () => Date

          Get a date representing "one week ago" relative to the mocked date

        • oneWeekFromNow: () => Date

          Get a date representing "one week from now" relative to the mocked date

        • oneMonthAgo: () => Date

          Get a date representing "one month ago" relative to the mocked date

        • oneMonthFromNow: () => Date

          Get a date representing "one month from now" relative to the mocked date

        • oneYearAgo: () => Date

          Get a date representing "one year ago" relative to the mocked date

        • oneYearFromNow: () => Date

          Get a date representing "one year from now" relative to the mocked date

        • startOfDay: () => Date

          Get the start of the day for the mocked date

        • endOfDay: () => Date

          Get the end of the day for the mocked date

        • startOfWeek: () => Date

          Get the start of the week for the mocked date

        • endOfWeek: () => Date

          Get the end of the week for the mocked date

        • startOfMonth: () => Date

          Get the start of the month for the mocked date

        • endOfMonth: () => Date

          Get the end of the month for the mocked date

        • startOfYear: () => Date

          Get the start of the year for the mocked date

        • endOfYear: () => Date

          Get the end of the year for the mocked date

        • expiredDate: () => Date

          Create an expired date (1 hour ago)

        • futureDate: () => Date

          Create a future date (1 hour from now)

        • isoString: () => string

          Create a date in ISO string format

        • unixTimestamp: () => number

          Create a Unix timestamp

        • jwtExpiration: () => number

          Create a date for JWT expiration (1 hour from now)

        • jwtIssuedAt: () => number

          Create a date for JWT issued at (current time)