From 6665dadd82ae833ed2f3bd4147cce41885d5c1d8 Mon Sep 17 00:00:00 2001 From: waiting <1661926154@qq.com> Date: Sat, 26 Oct 2024 14:26:52 +0800 Subject: [PATCH] test: use fs.rmSync() and rmdirSync() --- test/index.test.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/index.test.ts b/test/index.test.ts index f2ceb37..8741528 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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 () => { @@ -32,10 +32,10 @@ describe('/test/index.test.ts', () => { expect(content.includes('addMany(options?: grpc.IClientOptions): grpc.IClientWritableStreamService;')).toBeTruthy(); expect(content.includes('addEmpty(options?: grpc.IClientOptions): grpc.IClientUnaryService;')).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 () => { @@ -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 () => { @@ -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 () => { @@ -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 () => { @@ -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')); }); });