Skip to content

Commit 52ebf5d

Browse files
committed
fix: improve async-mutex mocking and reset instancePromise on cache close
1 parent 0432315 commit 52ebf5d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/autocomplete/util/AutocompleteLruCache.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import AutocompleteLruCache from "./AutocompleteLruCache";
22

3-
// Mock the external dependencies before importing
4-
jest.mock("async-mutex");
3+
jest.mock("async-mutex", () => {
4+
const acquire = jest.fn().mockResolvedValue(jest.fn());
5+
return {
6+
Mutex: jest.fn().mockImplementation(() => ({ acquire })),
7+
};
8+
});
59
jest.mock("sqlite");
610
jest.mock("sqlite3");
711

core/autocomplete/util/AutocompleteLruCache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class AutocompleteLruCache {
221221
}
222222
await this.flush();
223223
await this.db.close();
224+
AutocompleteLruCache.instancePromise = undefined;
224225
}
225226
}
226-
227227
export default AutocompleteLruCache;

0 commit comments

Comments
 (0)