Skip to content

Commit

Permalink
test: refactor some testing helper methods (#1346)
Browse files Browse the repository at this point in the history
Co-authored-by: souvik <[email protected]>
  • Loading branch information
peter-rr and Souvikns authored Apr 12, 2024
1 parent 78caf99 commit 95f15bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
19 changes: 2 additions & 17 deletions test/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/new/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +17,7 @@ describe('new', () => {

describe('create new file', () => {
afterEach(() => {
testHelper.newCommandHelper().deleteSpecFile();
testHelper.deleteSpecFileAtWorkingDir();
});

test
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('new', () => {
});

afterEach(() => {
testHelper.newCommandHelper().deleteSpecFile();
testHelper.deleteSpecFileAtWorkingDir();
});

test
Expand Down

0 comments on commit 95f15bd

Please sign in to comment.