From 51b013c587fb98a7277a3905d00a0339717c14dd Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Tue, 26 Sep 2023 17:13:02 -0400 Subject: [PATCH] fix: cleanup getEnvironmentConfig from nodejs, move tests --- .../config-manager}/__mocks__/cross-fetch.ts | 0 .../config-manager}/__mocks__/fetch-retry.ts | 0 .../config-manager}/__tests__/request.spec.ts | 5 +---- sdk/nodejs/src/request.ts | 19 ------------------- 4 files changed, 1 insertion(+), 23 deletions(-) rename {sdk/nodejs => lib/shared/config-manager}/__mocks__/cross-fetch.ts (100%) rename {sdk/nodejs => lib/shared/config-manager}/__mocks__/fetch-retry.ts (100%) rename {sdk/nodejs => lib/shared/config-manager}/__tests__/request.spec.ts (87%) diff --git a/sdk/nodejs/__mocks__/cross-fetch.ts b/lib/shared/config-manager/__mocks__/cross-fetch.ts similarity index 100% rename from sdk/nodejs/__mocks__/cross-fetch.ts rename to lib/shared/config-manager/__mocks__/cross-fetch.ts diff --git a/sdk/nodejs/__mocks__/fetch-retry.ts b/lib/shared/config-manager/__mocks__/fetch-retry.ts similarity index 100% rename from sdk/nodejs/__mocks__/fetch-retry.ts rename to lib/shared/config-manager/__mocks__/fetch-retry.ts diff --git a/sdk/nodejs/__tests__/request.spec.ts b/lib/shared/config-manager/__tests__/request.spec.ts similarity index 87% rename from sdk/nodejs/__tests__/request.spec.ts rename to lib/shared/config-manager/__tests__/request.spec.ts index c9ed0b37d..4c06f69b6 100644 --- a/sdk/nodejs/__tests__/request.spec.ts +++ b/lib/shared/config-manager/__tests__/request.spec.ts @@ -3,12 +3,9 @@ import fetch, { Response } from 'cross-fetch' global.fetch = fetch +import { getEnvironmentConfig } from '../src/request' const fetchRequestMock = fetch as jest.MockedFn -import { publishEvents, getEnvironmentConfig } from '../src/request' -import { dvcDefaultLogger } from '@devcycle/js-cloud-server-sdk' -const logger = dvcDefaultLogger() - describe('request.ts Unit Tests', () => { beforeEach(() => { fetchRequestMock.mockReset() diff --git a/sdk/nodejs/src/request.ts b/sdk/nodejs/src/request.ts index 01d31d3f9..a7c0829b2 100644 --- a/sdk/nodejs/src/request.ts +++ b/sdk/nodejs/src/request.ts @@ -6,25 +6,6 @@ export const HOST = '.devcycle.com' export const EVENT_URL = 'https://events' export const EVENTS_PATH = '/v1/events/batch' -export async function getEnvironmentConfig( - url: string, - requestTimeout: number, - etag?: string, -): Promise { - const headers: Record = etag - ? { 'If-None-Match': etag } - : {} - - return await getWithTimeout( - url, - { - headers: headers, - retries: 1, - }, - requestTimeout, - ) -} - export async function publishEvents( logger: DVCLogger, sdkKey: string,