fix: improve async-mutex mocking and reset instancePromise on cache close
This commit is contained in:
parent
04323155cd
commit
52ebf5d032
2 changed files with 7 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue