fix: improve async-mutex mocking and reset instancePromise on cache close

This commit is contained in:
Ayyan Shaikh
2025-10-21 11:28:45 +00:00
parent 04323155cd
commit 52ebf5d032
2 changed files with 7 additions and 3 deletions

View File

@@ -1,7 +1,11 @@
import AutocompleteLruCache from "./AutocompleteLruCache";
// Mock the external dependencies before importing
jest.mock("async-mutex");
jest.mock("async-mutex", () => {
const acquire = jest.fn().mockResolvedValue(jest.fn());
return {
Mutex: jest.fn().mockImplementation(() => ({ acquire })),
};
});
jest.mock("sqlite");
jest.mock("sqlite3");

View File

@@ -221,7 +221,7 @@ export class AutocompleteLruCache {
}
await this.flush();
await this.db.close();
AutocompleteLruCache.instancePromise = undefined;
}
}
export default AutocompleteLruCache;