Skip to content

Commit 67da947

Browse files
move test_utils to the top level
1 parent 9f7b933 commit 67da947

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

functions/translate_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SlackFunctionTester } from "deno-slack-sdk/mod.ts";
22
import { assert, assertEquals, assertNotEquals } from "@std/assert";
33
import handler from "./translate.ts";
4-
import { StubFetch } from "./test_utils.ts";
4+
import { StubFetch } from "../test_utils.ts";
55

66
// Replaces globalThis.fetch with the stub copy
77
const stubFetch = new StubFetch();
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ export class UnmatchedRequestError extends Error {
3737

3838
export class StubFetch {
3939
private stubs: Map<string, StubRequestHandler> = new Map();
40-
private stubFetchInstance: Stub | null = null;
40+
private stubFetchInstance: Stub;
4141

4242
/**
4343
* Creates a new StubFetch instance and automatically installs it.
4444
* The global fetch function is replaced with the stub immediately upon creation.
4545
*/
4646
constructor() {
47-
this.install();
47+
this.stubFetchInstance = this.install();
4848
}
4949

5050
/**
@@ -127,7 +127,6 @@ export class StubFetch {
127127
restore(): void {
128128
if (this.stubFetchInstance) {
129129
this.stubFetchInstance.restore();
130-
this.stubFetchInstance = null;
131130
}
132131
}
133132
}

0 commit comments

Comments
 (0)