From 95f15bd858069659bb810d61f5099fea9ff73c2c Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Fri, 12 Apr 2024 06:33:54 +0200 Subject: [PATCH] test: refactor some testing helper methods (#1346) Co-authored-by: souvik --- test/helpers/index.ts | 19 ++----------------- test/integration/new/file.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/test/helpers/index.ts b/test/helpers/index.ts index 65589b69ecd..fdddffc68e8 100644 --- a/test/helpers/index.ts +++ b/test/helpers/index.ts @@ -57,26 +57,11 @@ export default class ContextTestingHelper { } createSpecFileAtWorkingDir(): void { - if (!existsSync(ASYNCAPI_FILE_PATH)) { - writeFileSync(ASYNCAPI_FILE_PATH, ''); - } + writeFileSync(ASYNCAPI_FILE_PATH, ''); } deleteSpecFileAtWorkingDir(): void { - if (existsSync(ASYNCAPI_FILE_PATH)) { - unlinkSync(ASYNCAPI_FILE_PATH); - } - } - - newCommandHelper() { - return { - deleteSpecFile: () => { - const specificationFilePath = path.resolve(process.cwd(), 'specification.yaml'); - if (existsSync(specificationFilePath)) { - unlinkSync(specificationFilePath); - } - } - }; + unlinkSync(ASYNCAPI_FILE_PATH); } createDummyProjectDirectory(): void { diff --git a/test/integration/new/file.test.ts b/test/integration/new/file.test.ts index 37887068d0d..2fe078a860c 100644 --- a/test/integration/new/file.test.ts +++ b/test/integration/new/file.test.ts @@ -7,7 +7,7 @@ const testHelper = new TestHelper(); describe('new', () => { before(() => { try { - testHelper.newCommandHelper().deleteSpecFile(); + testHelper.deleteSpecFileAtWorkingDir(); } catch (e: any) { if (e.code !== 'ENOENT') { throw e; @@ -17,7 +17,7 @@ describe('new', () => { describe('create new file', () => { afterEach(() => { - testHelper.newCommandHelper().deleteSpecFile(); + testHelper.deleteSpecFileAtWorkingDir(); }); test @@ -53,7 +53,7 @@ describe('new', () => { }); afterEach(() => { - testHelper.newCommandHelper().deleteSpecFile(); + testHelper.deleteSpecFileAtWorkingDir(); }); test