mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-25 16:59:17 +01:00
Reintroduce null object remove rerouting (#8920)
* Reintroduce null object remove rerouting * Test remove redirect
This commit is contained in:
parent
1e4158fd87
commit
e516eec200
@ -78,6 +78,11 @@ export default abstract class AbstractChromeStorageService
|
||||
async save(key: string, obj: any): Promise<void> {
|
||||
obj = objToStore(obj);
|
||||
|
||||
if (obj == null) {
|
||||
// Safari does not support set of null values
|
||||
return this.remove(key);
|
||||
}
|
||||
|
||||
const keyedObj = { [key]: obj };
|
||||
return new Promise<void>((resolve) => {
|
||||
this.chromeStorageApi.set(keyedObj, () => {
|
||||
|
@ -62,6 +62,17 @@ describe("ChromeStorageApiService", () => {
|
||||
expect.any(Function),
|
||||
);
|
||||
});
|
||||
|
||||
it("removes the key when the value is null", async () => {
|
||||
const removeMock = chrome.storage.local.remove as jest.Mock;
|
||||
removeMock.mockImplementation((key, callback) => {
|
||||
delete store[key];
|
||||
callback();
|
||||
});
|
||||
const key = "key";
|
||||
await service.save(key, null);
|
||||
expect(removeMock).toHaveBeenCalledWith(key, expect.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe("get", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user