jest-webextension-mock 3.8.14 → 3.8.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/setup.js +16 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/setup.js
CHANGED
|
@@ -259,8 +259,10 @@ var createEventListeners = function createEventListeners() {
|
|
|
259
259
|
};
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
var
|
|
263
|
-
|
|
262
|
+
var syncStore = {};
|
|
263
|
+
var localStore = {};
|
|
264
|
+
var managedStore = {};
|
|
265
|
+
function resolveKey(key, store) {
|
|
264
266
|
if (typeof key === 'string') {
|
|
265
267
|
var result = {};
|
|
266
268
|
result[key] = store[key];
|
|
@@ -281,7 +283,7 @@ function resolveKey(key) {
|
|
|
281
283
|
var storage = {
|
|
282
284
|
sync: {
|
|
283
285
|
get: jest.fn(function (id, cb) {
|
|
284
|
-
var result = id === null ?
|
|
286
|
+
var result = id === null ? syncStore : resolveKey(id, syncStore);
|
|
285
287
|
if (cb !== undefined) {
|
|
286
288
|
return cb(result);
|
|
287
289
|
}
|
|
@@ -295,7 +297,7 @@ var storage = {
|
|
|
295
297
|
}),
|
|
296
298
|
set: jest.fn(function (payload, cb) {
|
|
297
299
|
Object.keys(payload).forEach(function (key) {
|
|
298
|
-
return
|
|
300
|
+
return syncStore[key] = payload[key];
|
|
299
301
|
});
|
|
300
302
|
if (cb !== undefined) {
|
|
301
303
|
return cb();
|
|
@@ -305,7 +307,7 @@ var storage = {
|
|
|
305
307
|
remove: jest.fn(function (id, cb) {
|
|
306
308
|
var keys = typeof id === 'string' ? [id] : id;
|
|
307
309
|
keys.forEach(function (key) {
|
|
308
|
-
return delete
|
|
310
|
+
return delete syncStore[key];
|
|
309
311
|
});
|
|
310
312
|
if (cb !== undefined) {
|
|
311
313
|
return cb();
|
|
@@ -313,7 +315,7 @@ var storage = {
|
|
|
313
315
|
return Promise.resolve();
|
|
314
316
|
}),
|
|
315
317
|
clear: jest.fn(function (cb) {
|
|
316
|
-
|
|
318
|
+
syncStore = {};
|
|
317
319
|
if (cb !== undefined) {
|
|
318
320
|
return cb();
|
|
319
321
|
}
|
|
@@ -323,7 +325,7 @@ var storage = {
|
|
|
323
325
|
},
|
|
324
326
|
local: {
|
|
325
327
|
get: jest.fn(function (id, cb) {
|
|
326
|
-
var result = id === null ?
|
|
328
|
+
var result = id === null ? localStore : resolveKey(id, localStore);
|
|
327
329
|
if (cb !== undefined) {
|
|
328
330
|
return cb(result);
|
|
329
331
|
}
|
|
@@ -337,7 +339,7 @@ var storage = {
|
|
|
337
339
|
}),
|
|
338
340
|
set: jest.fn(function (payload, cb) {
|
|
339
341
|
Object.keys(payload).forEach(function (key) {
|
|
340
|
-
return
|
|
342
|
+
return localStore[key] = payload[key];
|
|
341
343
|
});
|
|
342
344
|
if (cb !== undefined) {
|
|
343
345
|
return cb();
|
|
@@ -347,7 +349,7 @@ var storage = {
|
|
|
347
349
|
remove: jest.fn(function (id, cb) {
|
|
348
350
|
var keys = typeof id === 'string' ? [id] : id;
|
|
349
351
|
keys.forEach(function (key) {
|
|
350
|
-
return delete
|
|
352
|
+
return delete localStore[key];
|
|
351
353
|
});
|
|
352
354
|
if (cb !== undefined) {
|
|
353
355
|
return cb();
|
|
@@ -355,7 +357,7 @@ var storage = {
|
|
|
355
357
|
return Promise.resolve();
|
|
356
358
|
}),
|
|
357
359
|
clear: jest.fn(function (cb) {
|
|
358
|
-
|
|
360
|
+
localStore = {};
|
|
359
361
|
if (cb !== undefined) {
|
|
360
362
|
return cb();
|
|
361
363
|
}
|
|
@@ -365,7 +367,7 @@ var storage = {
|
|
|
365
367
|
},
|
|
366
368
|
managed: {
|
|
367
369
|
get: jest.fn(function (id, cb) {
|
|
368
|
-
var result = id === null ?
|
|
370
|
+
var result = id === null ? managedStore : resolveKey(id, managedStore);
|
|
369
371
|
if (cb !== undefined) {
|
|
370
372
|
return cb(result);
|
|
371
373
|
}
|
|
@@ -379,7 +381,7 @@ var storage = {
|
|
|
379
381
|
}),
|
|
380
382
|
set: jest.fn(function (payload, cb) {
|
|
381
383
|
Object.keys(payload).forEach(function (key) {
|
|
382
|
-
return
|
|
384
|
+
return managedStore[key] = payload[key];
|
|
383
385
|
});
|
|
384
386
|
if (cb !== undefined) {
|
|
385
387
|
return cb();
|
|
@@ -389,7 +391,7 @@ var storage = {
|
|
|
389
391
|
remove: jest.fn(function (id, cb) {
|
|
390
392
|
var keys = typeof id === 'string' ? [id] : id;
|
|
391
393
|
keys.forEach(function (key) {
|
|
392
|
-
return delete
|
|
394
|
+
return delete managedStore[key];
|
|
393
395
|
});
|
|
394
396
|
if (cb !== undefined) {
|
|
395
397
|
return cb();
|
|
@@ -397,7 +399,7 @@ var storage = {
|
|
|
397
399
|
return Promise.resolve();
|
|
398
400
|
}),
|
|
399
401
|
clear: jest.fn(function (cb) {
|
|
400
|
-
|
|
402
|
+
managedStore = {};
|
|
401
403
|
if (cb !== undefined) {
|
|
402
404
|
return cb();
|
|
403
405
|
}
|