From 010917607c7429f48541c7dce4dc999bc96fe7d3 Mon Sep 17 00:00:00 2001 From: Camden Phalen Date: Fri, 20 Dec 2024 12:02:32 -0500 Subject: [PATCH] Fix tests --- commands/project/__tests__/logs.test.ts | 4 +++- commands/project/logs.ts | 2 +- lib/__tests__/ProjectLogsManager.test.ts | 8 ++++---- lib/projects/ProjectLogsManager.ts | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/commands/project/__tests__/logs.test.ts b/commands/project/__tests__/logs.test.ts index 663405e1e..7faa46639 100644 --- a/commands/project/__tests__/logs.test.ts +++ b/commands/project/__tests__/logs.test.ts @@ -1,7 +1,9 @@ // @ts-nocheck const yargs = require('yargs'); const { addUseEnvironmentOptions } = require('../../../lib/commonOpts'); -const ProjectLogsManager = require('../../../lib/projects/ProjectLogsManager'); +const { + ProjectLogsManager, +} = require('../../../lib/projects/ProjectLogsManager'); const { projectLogsPrompt, } = require('../../../lib/prompts/projectsLogsPrompt'); diff --git a/commands/project/logs.ts b/commands/project/logs.ts index ed95041cf..ecd2228d6 100644 --- a/commands/project/logs.ts +++ b/commands/project/logs.ts @@ -15,7 +15,7 @@ const { uiBetaTag, uiLine, uiLink } = require('../../lib/ui'); const { projectLogsPrompt } = require('../../lib/prompts/projectsLogsPrompt'); const { i18n } = require('../../lib/lang'); const { EXIT_CODES } = require('../../lib/enums/exitCodes'); -const ProjectLogsManager = require('../../lib/projects/ProjectLogsManager'); +const { ProjectLogsManager } = require('../../lib/projects/ProjectLogsManager'); const i18nKey = 'commands.project.subcommands.logs'; diff --git a/lib/__tests__/ProjectLogsManager.test.ts b/lib/__tests__/ProjectLogsManager.test.ts index bd601d625..e6bffede6 100644 --- a/lib/__tests__/ProjectLogsManager.test.ts +++ b/lib/__tests__/ProjectLogsManager.test.ts @@ -1,5 +1,5 @@ // @ts-nocheck -const ProjectLogsManager = require('../projects/ProjectLogsManager'); +const { ProjectLogsManager } = require('../projects/ProjectLogsManager'); const { getProjectConfig, ensureProjectExists } = require('../projects'); const { fetchProjectComponentsMetadata, @@ -143,8 +143,8 @@ describe('lib/projects/ProjectLogsManager', () => { }); describe('getFunctionNames', () => { - it('should return an empty array if functions is nullable', async () => { - ProjectLogsManager.functions = undefined; + it('should return an empty array if functions is empty', async () => { + ProjectLogsManager.functions = []; expect(ProjectLogsManager.getFunctionNames()).toEqual([]); }); @@ -159,7 +159,7 @@ describe('lib/projects/ProjectLogsManager', () => { describe('setFunction', () => { it('should throw an error when functions is nullable', async () => { - ProjectLogsManager.functions = undefined; + ProjectLogsManager.functions = []; expect(() => ProjectLogsManager.setFunction('foo')).toThrow( `There aren't any functions in this project` ); diff --git a/lib/projects/ProjectLogsManager.ts b/lib/projects/ProjectLogsManager.ts index 251fb53e4..55288526d 100644 --- a/lib/projects/ProjectLogsManager.ts +++ b/lib/projects/ProjectLogsManager.ts @@ -7,7 +7,7 @@ import { uiLink } from '../ui'; const i18nKey = 'commands.project.subcommands.logs'; -class ProjectLogsManager { +class _ProjectLogsManager { projectName: string | undefined; projectId: number | undefined; accountId: number | undefined; @@ -153,4 +153,4 @@ class ProjectLogsManager { } } -export default new ProjectLogsManager(); +export const ProjectLogsManager = new _ProjectLogsManager();