Skip to content

Commit

Permalink
test: use fs.rmSync() and rmdirSync()
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Oct 26, 2024
1 parent 769ba7b commit 6665dad
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Compiler } from '../src';
import { existsSync } from 'fs';
import { existsSync, rmSync, rmdirSync } from 'fs';
import { join } from 'path';
import { remove, readFileSync } from 'fs-extra';
import { readFileSync } from 'fs-extra';

describe('/test/index.test.ts', () => {
it('test generate ts interface', async () => {
Expand Down Expand Up @@ -32,10 +32,10 @@ describe('/test/index.test.ts', () => {
expect(content.includes('addMany(options?: grpc.IClientOptions): grpc.IClientWritableStreamService<AddArgs, Num>;')).toBeTruthy();
expect(content.includes('addEmpty(options?: grpc.IClientOptions): grpc.IClientUnaryService<any, any>;')).toBeTruthy();

await remove(join(__dirname, './fixtures/common/test/hero.ts'));
await remove(join(__dirname, './fixtures/common/helloworld.ts'));
await remove(join(__dirname, './fixtures/common/math.ts'));
await remove(join(__dirname, './fixtures/common/hello_stream.ts'));
rmSync(join(__dirname, './fixtures/common/test/hero.ts'));
rmSync(join(__dirname, './fixtures/common/helloworld.ts'));
rmSync(join(__dirname, './fixtures/common/math.ts'));
rmSync(join(__dirname, './fixtures/common/hello_stream.ts'));
});

it('test generate ts interface to specified directory', async () => {
Expand All @@ -52,7 +52,7 @@ describe('/test/index.test.ts', () => {
expect(existsSync(join(__dirname, './fixtures/common/domain/helloworld.ts'))).toBeTruthy();
expect(existsSync(join(__dirname, './fixtures/common/domain/math.ts'))).toBeTruthy();

await remove(join(__dirname, './fixtures/common/domain'));
rmdirSync(join(__dirname, './fixtures/common/domain'));
});

it('test generate ts interface to specified directory with reserve directory', async () => {
Expand All @@ -70,7 +70,7 @@ describe('/test/index.test.ts', () => {
expect(existsSync(join(__dirname, './fixtures/common/domain/helloworld.ts'))).toBeTruthy();
expect(existsSync(join(__dirname, './fixtures/common/domain/math.ts'))).toBeTruthy();

await remove(join(__dirname, './fixtures/common/domain'));
rmdirSync(join(__dirname, './fixtures/common/domain'));
});

it('test generate ts interface keep case', async () => {
Expand All @@ -88,7 +88,7 @@ describe('/test/index.test.ts', () => {
const content = readFileSync(join(__dirname, './fixtures/keep_case/domain/helloworld_keep_case.ts'), 'utf8');
expect(content.includes('key_filed')).toBeTruthy();

await remove(join(__dirname, './fixtures/keep_case/domain'));
rmdirSync(join(__dirname, './fixtures/keep_case/domain'));
});

it.skip('test fix issue 999', async () => {
Expand Down Expand Up @@ -119,6 +119,6 @@ describe('/test/index.test.ts', () => {
expect(!content.includes('namespace base')).toBeTruthy();
expect(!content.includes('namespace gogo')).toBeTruthy();

await remove(join(__dirname, './fixtures/issue999/domain'));
rmdirSync(join(__dirname, './fixtures/issue999/domain'));
});
});

0 comments on commit 6665dad

Please sign in to comment.