1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-20 21:01:29 +01:00

fix browser state service tests

This commit is contained in:
Jacob Fink 2023-06-30 11:20:13 -04:00
parent e66ae53bf9
commit 6068421df7
No known key found for this signature in database
GPG Key ID: C2F7ACF05859D008
2 changed files with 11 additions and 8 deletions

View File

@ -41,7 +41,8 @@ describe("Browser State Service", () => {
logService = mock();
stateMigrationService = mock();
stateFactory = mock();
useAccountCache = true;
// turn off account cache for tests
useAccountCache = false;
state = new State(new GlobalState());
state.accounts[userId] = new Account({

View File

@ -58,15 +58,17 @@ export class BrowserStateService
// TODO: This is a hack to fix having a disk cache on both the popup and
// the background page that can get out of sync. We need to have a single
// instance of our state service that is shared so we can remove this.
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === "local") {
for (const key of Object.keys(changes)) {
if (key !== "accountActivity" && this.accountDiskCache.value[key]) {
this.deleteDiskCache(key);
if (useAccountCache) {
chrome.storage.onChanged.addListener((changes, namespace) => {
if (namespace === "local") {
for (const key of Object.keys(changes)) {
if (key !== "accountActivity" && this.accountDiskCache.value[key]) {
this.deleteDiskCache(key);
}
}
}
}
});
});
}
}
async addAccount(account: Account) {