MCPcopy Index your code
hub / github.com/angular/angular / FakeFileSystemAPI

Class FakeFileSystemAPI

adev/shared-docs/testing/testing-helper.ts:109–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109class FakeFileSystemAPI implements FileSystemAPI {
110 readdir(
111 path: string,
112 options: 'buffer' | {encoding: 'buffer'; withFileTypes?: false | undefined},
113 ): Promise<Uint8Array[]>;
114 readdir(
115 path: string,
116 options?:
117 | string
118 | {encoding?: string | null | undefined; withFileTypes?: false | undefined}
119 | null
120 | undefined,
121 ): Promise<string[]>;
122 readdir(
123 path: string,
124 options: {encoding: 'buffer'; withFileTypes: true},
125 ): Promise<DirEnt<Uint8Array>[]>;
126 readdir(
127 path: string,
128 options: {encoding?: string | null | undefined; withFileTypes: true},
129 ): Promise<DirEnt<string>[]>;
130 async readdir(
131 path: unknown,
132 options?: {encoding?: string | null | undefined; withFileTypes?: boolean} | string | null,
133 ): Promise<Uint8Array[] | string[] | DirEnt<Uint8Array>[] | DirEnt<string>[]> {
134 if (typeof options === 'object' && options?.withFileTypes === true) {
135 return [{name: 'fake-file', isFile: () => true, isDirectory: () => false}];
136 }
137
138 return ['/fake-dirname'];
139 }
140
141 readFile(path: string, encoding?: null | undefined): Promise<Uint8Array>;
142 readFile(path: string, encoding: string): Promise<string>;
143 readFile(path: unknown, encoding?: unknown): Promise<Uint8Array> | Promise<string> {
144 return Promise.resolve('fake file content');
145 }
146 async writeFile(
147 path: string,
148 data: string | Uint8Array,
149 options?: string | {encoding?: string | null | undefined} | null | undefined,
150 ): Promise<void> {}
151
152 mkdir(path: string, options?: {recursive?: false | undefined} | undefined): Promise<void>;
153 mkdir(path: string, options: {recursive: true}): Promise<string>;
154 async mkdir(path: unknown, options?: unknown): Promise<void | string> {}
155
156 async rm(
157 path: string,
158 options?: {force?: boolean | undefined; recursive?: boolean | undefined} | undefined,
159 ): Promise<void> {}
160
161 rename(oldPath: string, newPath: string): Promise<void> {
162 throw Error('Not implemented');
163 }
164
165 watch(
166 filename: string,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…