@applicaster/zapp-react-dom-app 13.0.0-rc.76 → 13.0.0-rc.77

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.
@@ -31,31 +31,3 @@ exports[`storageObject when the requested storage exists getAllItems returns all
31
31
  "otherKey": "otherValue",
32
32
  }
33
33
  `;
34
-
35
- exports[`storageObject when the requested storage exists getItem gets properties from the storage 1`] = `"bar"`;
36
-
37
- exports[`storageObject when the requested storage exists getItem gets properties from the storage 2`] = `"bar"`;
38
-
39
- exports[`storageObject when the requested storage exists getItem gets properties from the storage 3`] = `"bar"`;
40
-
41
- exports[`storageObject when the requested storage exists getItem gets properties from the storage 4`] = `"bar"`;
42
-
43
- exports[`storageObject when the requested storage exists getItem gets properties from the storage with a namespace 1`] = `"baz"`;
44
-
45
- exports[`storageObject when the requested storage exists getItem gets properties from the storage with a namespace 2`] = `"baz"`;
46
-
47
- exports[`storageObject when the requested storage exists getItem rejects if the property cannot be retrieved 1`] = `[Error: Could not retrieve item applicaster.v2_::_fail_key]`;
48
-
49
- exports[`storageObject when the requested storage exists getItem rejects if the property cannot be retrieved 2`] = `[Error: Could not retrieve item applicaster.v2_::_fail_key]`;
50
-
51
- exports[`storageObject when the requested storage exists removeItem removes an item 1`] = `true`;
52
-
53
- exports[`storageObject when the requested storage exists removeItem removes an item 2`] = `true`;
54
-
55
- exports[`storageObject when the requested storage exists removeItem removes an item 3`] = `true`;
56
-
57
- exports[`storageObject when the requested storage exists removeItem removes an item 4`] = `true`;
58
-
59
- exports[`storageObject when the requested storage exists setItem will reject a promise if it the setting of the data fails 1`] = `[Error: Could not set item applicaster.v2_::_fail_key]`;
60
-
61
- exports[`storageObject when the requested storage exists setItem will reject a promise if it the setting of the data fails 2`] = `[Error: Could not set item applicaster.v2_::_fail_key]`;
@@ -4,7 +4,8 @@ import {
4
4
  applyNamespaceToKeyName,
5
5
  STORAGE_TYPES,
6
6
  DEFAULT_NAMESPACE,
7
- } from "../index";
7
+ } from "../";
8
+
8
9
  import { StorageMock } from "./StorageMocks";
9
10
 
10
11
  import * as functionUtils from "@applicaster/zapp-react-native-utils/functionUtils";
@@ -26,14 +27,7 @@ function clearStorage() {
26
27
  R.forEach((storage) => global.window[storage].clear(), STORAGE_TYPES);
27
28
  }
28
29
 
29
- async function testStorage(expectations) {
30
- await Promise.all(
31
- R.map((storage) => {
32
- const Storage = getStorageModule(storage);
33
- expectations(Storage);
34
- }, STORAGE_TYPES)
35
- );
36
- }
30
+ const storages = R.map((storage) => getStorageModule(storage), STORAGE_TYPES);
37
31
 
38
32
  describe("storageObject", () => {
39
33
  beforeEach(resetMocks);
@@ -48,143 +42,119 @@ describe("storageObject", () => {
48
42
 
49
43
  beforeEach(clearStorage);
50
44
 
51
- it("returns an object with 3 methods", () => {
52
- expect.assertions(6);
53
-
54
- testStorage((Storage) => {
55
- expect(Storage).toHaveProperty("setItem");
56
- expect(Storage).toHaveProperty("getItem");
57
- expect(Storage).toHaveProperty("getAllItems");
58
- });
45
+ it.each(storages)("returns an object with 3 methods", (storage) => {
46
+ expect(storage).toHaveProperty("setItem");
47
+ expect(storage).toHaveProperty("getItem");
48
+ expect(storage).toHaveProperty("getAllItems");
59
49
  });
60
50
 
61
51
  describe("setItem", () => {
62
52
  beforeEach(clearStorage);
63
53
 
64
- it("sets a property in the storage", async () => {
65
- expect.assertions(4);
54
+ it.each(storages)("sets a property in the storage", async (storage) => {
55
+ const result = await storage.setItem(key, value, null);
66
56
 
67
- await testStorage(async (Storage) => {
68
- const result = await Storage.setItem(key, value, null);
57
+ const keyWithDefaultNameSpace = applyNamespaceToKeyName(
58
+ key,
59
+ DEFAULT_NAMESPACE
60
+ );
69
61
 
70
- const keyWithDefaultNameSpace = applyNamespaceToKeyName(
71
- key,
72
- DEFAULT_NAMESPACE
73
- );
62
+ expect(result).toBe(true);
74
63
 
75
- expect(result).toBe(true);
76
- expect(Storage[keyWithDefaultNameSpace]).toEqual(value);
77
- });
64
+ expect(storage.getItem(keyWithDefaultNameSpace)).resolves.toEqual(
65
+ value
66
+ );
78
67
  });
79
68
 
80
- it("sets a property in the storage with a namespace", async () => {
81
- expect.assertions(4);
82
-
83
- await testStorage(async (Storage) => {
84
- const result = await Storage.setItem(key, namespaceValue, namespace);
69
+ it.each(storages)(
70
+ "sets a property in the storage with a namespace",
71
+ async (storage) => {
72
+ const result = await storage.setItem(key, namespaceValue, namespace);
85
73
 
86
74
  expect(result).toBe(true);
87
- expect(Storage[keyName]).toEqual(namespaceValue);
88
- });
89
- });
90
75
 
91
- it("will reject a promise if it the setting of the data fails", async () => {
92
- expect.assertions(2);
76
+ expect(storage.getItem(keyName)).resolves.toEqual(namespaceValue);
77
+ }
78
+ );
93
79
 
94
- await testStorage(async (Storage) => {
95
- await expect(
96
- Storage.setItem(failKey, value)
97
- ).rejects.toMatchSnapshot();
98
- });
99
- });
80
+ it.each(storages)(
81
+ "will reject a promise if it the setting of the data fails",
82
+ async (storage) => {
83
+ await expect(storage.setItem(failKey, value)).rejects.toThrow(
84
+ "Could not set item applicaster.v2_::_fail_key"
85
+ );
86
+ }
87
+ );
100
88
  });
101
89
 
102
90
  describe("getItem", () => {
103
91
  beforeEach(async () => {
104
92
  clearStorage();
105
93
 
106
- await testStorage(async (Storage) => {
94
+ storages.forEach((Storage) => {
107
95
  Storage.setItem(key, value, null);
108
96
  Storage.setItem(key, namespaceValue, namespace);
109
97
  });
110
98
  });
111
99
 
112
- it("gets properties from the storage", async () => {
113
- expect.assertions(8);
114
-
115
- await testStorage(async (Storage) => {
116
- await expect(Storage.getItem(key)).resolves.toEqual(value);
117
- await expect(Storage.getItem(key)).resolves.toMatchSnapshot();
118
- await expect(Storage.getItem(key, null)).resolves.toEqual(value);
119
- await expect(Storage.getItem(key, null)).resolves.toMatchSnapshot();
120
- });
100
+ it.each(storages)("gets properties from the storage", async (storage) => {
101
+ const result = await storage.getItem(key);
102
+ const resultWithNull = await storage.getItem(key, null);
103
+ expect(result).toEqual(value);
104
+ expect(resultWithNull).toEqual(value);
121
105
  });
122
106
 
123
- it("gets properties from the storage with a namespace", async () => {
124
- expect.assertions(4);
125
-
126
- await testStorage(async (Storage) => {
127
- await expect(Storage.getItem(key, namespace)).resolves.toEqual(
128
- namespaceValue
107
+ it.each(storages)(
108
+ "gets properties from the storage with a namespace",
109
+ (storage) => {
110
+ expect(storage.getItem(key, namespace)).resolves.toEqual(
111
+ "namespaceValue"
129
112
  );
113
+ }
114
+ );
130
115
 
131
- await expect(
132
- Storage.getItem(key, namespace)
133
- ).resolves.toMatchSnapshot();
134
- });
135
- });
136
-
137
- it("rejects if the property cannot be retrieved", async () => {
138
- expect.assertions(2);
139
-
140
- await testStorage(async (Storage) => {
141
- await expect(Storage.getItem(failKey)).rejects.toMatchSnapshot();
142
- });
143
- });
116
+ it.each(storages)(
117
+ "rejects if the property cannot be retrieved",
118
+ async (storage) => {
119
+ await expect(storage.getItem(failKey)).rejects.toThrow(
120
+ "Could not retrieve item applicaster.v2_::_fail_key"
121
+ );
122
+ }
123
+ );
144
124
  });
145
125
 
146
126
  describe("getAllItems", () => {
147
127
  beforeEach(async () => {
148
128
  clearStorage();
149
129
 
150
- await testStorage(async (Storage) => {
151
- await Storage.setItem(key, value);
152
- await Storage.setItem(key, namespaceValue, namespace);
153
- await Storage.setItem("otherKey", "otherValue");
154
- await Storage.setItem("otherKey", "otherValue", namespace);
130
+ storages.forEach((Storage) => {
131
+ Storage.setItem(key, value);
132
+ Storage.setItem(key, namespaceValue, namespace);
133
+ Storage.setItem("otherKey", "otherValue");
134
+ Storage.setItem("otherKey", "otherValue", namespace);
155
135
  });
156
136
  });
157
137
 
158
- it("returns all keys", async () => {
159
- expect.assertions(2);
160
-
161
- await testStorage(async (Storage) => {
162
- await expect(Storage.getAllItems()).resolves.toMatchSnapshot();
163
- });
138
+ it.each(storages)("returns all keys", async (Storage) => {
139
+ const res = await Storage.getAllItems();
140
+ expect(res).toMatchSnapshot();
164
141
  });
165
142
 
166
- it("returns all keys in the namespace if provided", async () => {
167
- expect.assertions(2);
168
-
169
- await testStorage(async (Storage) => {
143
+ it.each(storages)(
144
+ "returns all keys in the namespace if provided",
145
+ async (Storage) => {
170
146
  await expect(
171
147
  Storage.getAllItems(namespace)
172
148
  ).resolves.toMatchSnapshot();
173
- });
174
- });
149
+ }
150
+ );
175
151
  });
176
152
 
177
153
  describe("removeItem", () => {
178
- it("removes an item", async () => {
179
- expect.assertions(4);
180
-
181
- await testStorage(async (Storage) => {
182
- await expect(Storage.removeItem(key)).resolves.toMatchSnapshot();
154
+ it.each(storages)("removes an item", async (Storage) => {
155
+ await expect(Storage.removeItem(key)).resolves.toBeTruthy();
183
156
 
184
- await expect(
185
- Storage.removeItem(key, namespace)
186
- ).resolves.toMatchSnapshot();
187
- });
157
+ await expect(Storage.removeItem(key, namespace)).resolves.toBeTruthy();
188
158
  });
189
159
  });
190
160
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-dom-app",
3
- "version": "13.0.0-rc.76",
3
+ "version": "13.0.0-rc.77",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
24
24
  "dependencies": {
25
- "@applicaster/zapp-react-dom-ui-components": "13.0.0-rc.76",
26
- "@applicaster/zapp-react-native-bridge": "13.0.0-rc.76",
27
- "@applicaster/zapp-react-native-redux": "13.0.0-rc.76",
28
- "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.76",
29
- "@applicaster/zapp-react-native-utils": "13.0.0-rc.76",
25
+ "@applicaster/zapp-react-dom-ui-components": "13.0.0-rc.77",
26
+ "@applicaster/zapp-react-native-bridge": "13.0.0-rc.77",
27
+ "@applicaster/zapp-react-native-redux": "13.0.0-rc.77",
28
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.77",
29
+ "@applicaster/zapp-react-native-utils": "13.0.0-rc.77",
30
30
  "abortcontroller-polyfill": "^1.7.5",
31
31
  "react-router-dom": "^5.1.2",
32
32
  "typeface-montserrat": "^0.0.54",