-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check the cache before acquiring lock to avoid latency (#558)
Co-authored-by: Steve Hobbs <[email protected]>
- Loading branch information
1 parent
7b2ab40
commit d434f73
Showing
4 changed files
with
101 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
export const acquireLockMock = jest.fn(); | ||
export const releaseLockMock = jest.fn(); | ||
const Lock = jest.requireActual('browser-tabs-lock').default; | ||
|
||
export default class FakeLock { | ||
acquireLock = acquireLockMock; | ||
releaseLock = releaseLockMock; | ||
export const acquireLockSpy = jest.fn(); | ||
export const releaseLockSpy = jest.fn(); | ||
|
||
export default class extends Lock { | ||
acquireLock(...args) { | ||
acquireLockSpy(...args); | ||
return super.acquireLock(...args); | ||
} | ||
releaseLock(...args) { | ||
releaseLockSpy(...args); | ||
return super.releaseLock(...args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters