jest-webextension-mock 3.8.15 → 3.8.16

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # jest-webextension-mock
2
2
 
3
+ ## 3.8.16
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix storage.get method throwing when not provided with a key
8
+
3
9
  ## 3.8.15
4
10
 
5
11
  ### Patch Changes
@@ -55,6 +55,9 @@ describe('browser.storage', () => {
55
55
  expect(e.message).toBe('Wrong key given');
56
56
  }
57
57
  });
58
+ test('an undefined key', () => {
59
+ return expect(storage.get()).resolves.toEqual({});
60
+ });
58
61
  afterEach(() => {
59
62
  expect(storage.get).toHaveBeenCalledTimes(1);
60
63
  storage.clear();
package/dist/setup.js CHANGED
@@ -283,7 +283,7 @@ function resolveKey(key, store) {
283
283
  var storage = {
284
284
  sync: {
285
285
  get: jest.fn(function (id, cb) {
286
- var result = id === null ? syncStore : resolveKey(id, syncStore);
286
+ var result = id === null || id === undefined ? syncStore : resolveKey(id, syncStore);
287
287
  if (cb !== undefined) {
288
288
  return cb(result);
289
289
  }
@@ -325,7 +325,7 @@ var storage = {
325
325
  },
326
326
  local: {
327
327
  get: jest.fn(function (id, cb) {
328
- var result = id === null ? localStore : resolveKey(id, localStore);
328
+ var result = id === null || id === undefined ? localStore : resolveKey(id, localStore);
329
329
  if (cb !== undefined) {
330
330
  return cb(result);
331
331
  }
@@ -367,7 +367,7 @@ var storage = {
367
367
  },
368
368
  managed: {
369
369
  get: jest.fn(function (id, cb) {
370
- var result = id === null ? managedStore : resolveKey(id, managedStore);
370
+ var result = id === null || id === undefined ? managedStore : resolveKey(id, managedStore);
371
371
  if (cb !== undefined) {
372
372
  return cb(result);
373
373
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-webextension-mock",
3
- "version": "3.8.15",
3
+ "version": "3.8.16",
4
4
  "description": "Mock the components of a WebExtension",
5
5
  "main": "dist/setup.js",
6
6
  "module": "src/setup.js",
package/src/storage.js CHANGED
@@ -26,7 +26,8 @@ function resolveKey(key, store) {
26
26
  export const storage = {
27
27
  sync: {
28
28
  get: jest.fn((id, cb) => {
29
- const result = id === null ? syncStore : resolveKey(id, syncStore);
29
+ const result =
30
+ id === null || id === undefined ? syncStore : resolveKey(id, syncStore);
30
31
  if (cb !== undefined) {
31
32
  return cb(result);
32
33
  }
@@ -64,7 +65,10 @@ export const storage = {
64
65
  },
65
66
  local: {
66
67
  get: jest.fn((id, cb) => {
67
- const result = id === null ? localStore : resolveKey(id, localStore);
68
+ const result =
69
+ id === null || id === undefined
70
+ ? localStore
71
+ : resolveKey(id, localStore);
68
72
  if (cb !== undefined) {
69
73
  return cb(result);
70
74
  }
@@ -102,7 +106,10 @@ export const storage = {
102
106
  },
103
107
  managed: {
104
108
  get: jest.fn((id, cb) => {
105
- const result = id === null ? managedStore : resolveKey(id, managedStore);
109
+ const result =
110
+ id === null || id === undefined
111
+ ? managedStore
112
+ : resolveKey(id, managedStore);
106
113
  if (cb !== undefined) {
107
114
  return cb(result);
108
115
  }