From 2f96ba96a02a7b3584fc75d413b050cfd0854008 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Thu, 27 Mar 2025 09:07:26 +0000 Subject: [PATCH] refactor(docs-infra): minor clean up in testing helpers (#60581) Modernize code of testing-helper PR Close #60581 --- adev/shared-docs/testing/testing-helper.ts | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/adev/shared-docs/testing/testing-helper.ts b/adev/shared-docs/testing/testing-helper.ts index eef8824f7fa..7c972b2c5b2 100644 --- a/adev/shared-docs/testing/testing-helper.ts +++ b/adev/shared-docs/testing/testing-helper.ts @@ -138,19 +138,15 @@ class FakeFileSystemAPI implements FileSystemAPI { path: string, options: {encoding?: string | null | undefined; withFileTypes: true}, ): Promise[]>; - readdir( + async readdir( path: unknown, options?: {encoding?: string | null | undefined; withFileTypes?: boolean} | string | null, - ): - | Promise - | Promise - | Promise[]> - | Promise[]> { + ): Promise[] | DirEnt[]> { if (typeof options === 'object' && options?.withFileTypes === true) { - return Promise.resolve([{name: 'fake-file', isFile: () => true, isDirectory: () => false}]); + return [{name: 'fake-file', isFile: () => true, isDirectory: () => false}]; } - return Promise.resolve(['/fake-dirname']); + return ['/fake-dirname']; } readFile(path: string, encoding?: null | undefined): Promise; @@ -158,28 +154,25 @@ class FakeFileSystemAPI implements FileSystemAPI { readFile(path: unknown, encoding?: unknown): Promise | Promise { return Promise.resolve('fake file content'); } - writeFile( + async writeFile( path: string, data: string | Uint8Array, options?: string | {encoding?: string | null | undefined} | null | undefined, - ): Promise { - return Promise.resolve(); - } + ): Promise {} + mkdir(path: string, options?: {recursive?: false | undefined} | undefined): Promise; mkdir(path: string, options: {recursive: true}): Promise; - mkdir(path: unknown, options?: unknown): Promise | Promise { - return Promise.resolve(); - } - rm( + async mkdir(path: unknown, options?: unknown): Promise {} + + async rm( path: string, options?: {force?: boolean | undefined; recursive?: boolean | undefined} | undefined, - ): Promise { - return Promise.resolve(); - } + ): Promise {} rename(oldPath: string, newPath: string): Promise { throw Error('Not implemented'); } + watch( filename: string, options?: FSWatchOptions | undefined,