From 7d52419d6f2e5e74ad81f1ac8175cb29a29e9ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Mon, 25 Mar 2024 17:59:42 +0100 Subject: [PATCH] refactor(core): Remove dead utils (no-changelog) (#8947) --- packages/cli/src/utils.ts | 12 ----------- packages/core/src/utils.ts | 5 ----- packages/core/test/utils.test.ts | 35 -------------------------------- 3 files changed, 52 deletions(-) delete mode 100644 packages/core/src/utils.ts delete mode 100644 packages/core/test/utils.test.ts diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts index 72d020e96d..6926c825bf 100644 --- a/packages/cli/src/utils.ts +++ b/packages/cli/src/utils.ts @@ -39,18 +39,6 @@ export const findSubworkflowStart = findWorkflowStart('integrated'); export const findCliWorkflowStart = findWorkflowStart('cli'); -export const alphabetizeKeys = (obj: INode) => - Object.keys(obj) - .sort() - .reduce>( - (acc, key) => ({ - ...acc, - // @ts-expect-error @TECH_DEBT Adding index signature to INode causes type issues downstream - [key]: obj[key], - }), - {}, - ); - export const separate = (array: T[], test: (element: T) => boolean) => { const pass: T[] = []; const fail: T[] = []; diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts deleted file mode 100644 index 991044ad41..0000000000 --- a/packages/core/src/utils.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { DateTime } from 'luxon'; - -export function toUtcDate(datetime: Date, tz: string) { - return DateTime.fromISO(datetime.toISOString().slice(0, -1), { zone: tz }).toUTC().toJSDate(); -} diff --git a/packages/core/test/utils.test.ts b/packages/core/test/utils.test.ts deleted file mode 100644 index a155b72e1c..0000000000 --- a/packages/core/test/utils.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { toUtcDate } from '@/utils'; - -describe('utils', () => { - describe('toUtcDate()', () => { - test('should convert to UTC date by adding', () => { - const originalDate = new Date('2020-01-01T00:00:00.000Z'); - const timezone = 'America/New_York'; // +5 to reach Z - - const utcDate = toUtcDate(originalDate, timezone); - - expect(utcDate).toBeInstanceOf(Date); - expect(utcDate.toISOString()).toBe('2020-01-01T05:00:00.000Z'); - }); - - test('should convert to UTC date by subtracting', () => { - const originalDate = new Date('2020-01-01T00:00:00.000Z'); - const timezone = 'Europe/Paris'; // -1 to reach Z - - const utcDate = toUtcDate(originalDate, timezone); - - expect(utcDate).toBeInstanceOf(Date); - expect(utcDate.toISOString()).toBe('2019-12-31T23:00:00.000Z'); - }); - - test('should convert to UTC date when already UTC', () => { - const originalDate = new Date('2020-01-01T00:00:00.000Z'); - const timezone = 'UTC'; // already at Z - - const utcDate = toUtcDate(originalDate, timezone); - - expect(utcDate).toBeInstanceOf(Date); - expect(utcDate.toISOString()).toBe('2020-01-01T00:00:00.000Z'); - }); - }); -});