backend-test-utils: rename MockDirectory.cleanup -> .remove

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-09-21 12:55:27 +02:00
parent a250ad775f
commit 3f3714ab41
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -37,7 +37,6 @@ export function isDockerDisabledForTests(): boolean;
// @public
export class MockDirectory {
addContent(root: MockDirectoryContent): Promise<void>;
cleanup: () => Promise<void>;
clear: () => Promise<void>;
content(
options?: MockDirectoryContentOptions,
@@ -45,6 +44,7 @@ export class MockDirectory {
static create(options?: MockDirectoryCreateOptions): MockDirectory;
static mockOsTmpDir(): MockDirectory;
get path(): string;
remove: () => Promise<void>;
resolve(...paths: string[]): string;
setContent(root: MockDirectoryContent): Promise<void>;
}
@@ -138,10 +138,10 @@ export class MockDirectory {
const shouldCleanup = !options?.root || !fs.pathExistsSync(options.root);
if (shouldCleanup) {
process.on('beforeExit', mocker.#cleanupSync);
process.on('beforeExit', mocker.#removeSync);
try {
afterAll(mocker.cleanup);
afterAll(mocker.remove);
} catch {
/* ignore */
}
@@ -208,7 +208,7 @@ export class MockDirectory {
* ```
*/
async setContent(root: MockDirectoryContent): Promise<void> {
await this.cleanup();
await this.remove();
return this.addContent(root);
}
@@ -331,7 +331,7 @@ export class MockDirectory {
/**
* Removes the mock directory and all its contents.
*/
cleanup = async (): Promise<void> => {
remove = async (): Promise<void> => {
await fs.rm(this.#root, { recursive: true, force: true });
};
@@ -361,7 +361,7 @@ export class MockDirectory {
return entries;
}
#cleanupSync = () => {
#removeSync = () => {
fs.rmSync(this.#root, { recursive: true, force: true });
};
}