From 3c96e122b4a97eb0c15839100bdc2c5509905069 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Fri, 8 Mar 2024 13:37:53 +0000 Subject: [PATCH] fix: Broken timezone-select.test.tsx after DST change (#14035) * fix: Broken timezone-select.test.tsx after DST change * Surpress minor lint error --- .../form/timezone-select/timezone-select.test.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/ui/components/form/timezone-select/timezone-select.test.tsx b/packages/ui/components/form/timezone-select/timezone-select.test.tsx index a9eeea7fbb..f24a9cf6c6 100644 --- a/packages/ui/components/form/timezone-select/timezone-select.test.tsx +++ b/packages/ui/components/form/timezone-select/timezone-select.test.tsx @@ -3,6 +3,8 @@ import { render, screen, waitFor, fireEvent } from "@testing-library/react"; import type { Props as SelectProps } from "react-timezone-select"; import { vi } from "vitest"; +import dayjs from "@calcom/dayjs"; + import { TimezoneSelect } from "./TimezoneSelect"; const cityTimezonesMock = [ @@ -32,14 +34,13 @@ const runtimeMock = async (isPending: boolean) => { mockedLib.trpc = updatedTrcp; }; -const optionMockValues = [ - "America/Dawson GMT -8:00", - "Pacific/Honolulu GMT -10:00", - "America/Juneau GMT -9:00", - "America/Toronto GMT -5:00", -]; +const formatOffset = (offset: string) => + offset.replace(/^([-+])(0)(\d):00$/, (_, sign, _zero, hour) => `${sign}${hour}:00`); +const formatTimeZoneWithOffset = (timeZone: string) => + `${timeZone} GMT ${formatOffset(dayjs.tz(undefined, timeZone).format("Z"))}`; const timezoneMockValues = ["America/Dawson", "Pacific/Honolulu", "America/Juneau", "America/Toronto"]; +const optionMockValues = timezoneMockValues.map(formatTimeZoneWithOffset); const classNames = { singleValue: () => "test1",