Skip to content

Commit

Permalink
fix: align mock of multiMerge with actual behavior (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Jan 11, 2022
1 parent bcaf152 commit 2dee293
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions jest/async-storage-mock.js
Expand Up @@ -94,14 +94,12 @@ async function _getAllKeys() {

async function _multiMerge(keyValuePairs, callback) {
keyValuePairs.forEach((keyValue) => {
const key = keyValue[0];
const value = JSON.parse(keyValue[1]);

const oldValue = JSON.parse(asMock.__INTERNAL_MOCK_STORAGE__[key]);

asMock.__INTERNAL_MOCK_STORAGE__[key] = JSON.stringify(
merge(oldValue, value),
);
const [key, value] = keyValue;
const oldValue = asMock.__INTERNAL_MOCK_STORAGE__[key];
asMock.__INTERNAL_MOCK_STORAGE__[key] =
oldValue != null
? JSON.stringify(merge(JSON.parse(oldValue), JSON.parse(value)))
: value;
});

callback && callback(null);
Expand Down

0 comments on commit 2dee293

Please sign in to comment.