fix: improve async-mutex mocking and reset instancePromise on cache close
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ export class AutocompleteLruCache {
|
||||
}
|
||||
await this.flush();
|
||||
await this.db.close();
|
||||
AutocompleteLruCache.instancePromise = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export default AutocompleteLruCache;
|
||||
|
||||
Reference in New Issue
Block a user