summaryrefslogtreecommitdiffstats
path: root/frontend/lib/testUtils.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-05-07 16:54:27 -0400
committerWes Bos <wesbos@gmail.com>2018-05-07 16:54:27 -0400
commitc9a2b488c83dcaae0a00d2177d3bfe1f185c28bf (patch)
treeee3b0ad93874e434a212b43194286f366f13fbe1 /frontend/lib/testUtils.js
parentdbd39fcc3861facecdd4413c90ae85cebd5db67f (diff)
TEST ESTSE TS ETSETST
Diffstat (limited to 'frontend/lib/testUtils.js')
-rw-r--r--frontend/lib/testUtils.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/frontend/lib/testUtils.js b/frontend/lib/testUtils.js
index 6b7132a..42739e9 100644
--- a/frontend/lib/testUtils.js
+++ b/frontend/lib/testUtils.js
@@ -25,6 +25,7 @@ const fakeUser = () => ({
});
const fakeOrderItem = () => ({
+ __typename: 'OrderItem',
id: casual.uuid,
image: `${casual.word}.jpg`,
title: casual.words(),
@@ -52,4 +53,27 @@ const fakeCartItem = overrides => ({
...overrides,
});
-export { fakeItem, fakeUser, fakeCartItem, fakeOrder, fakeOrderItem };
+// Fake LocalStorage
+class LocalStorageMock {
+ constructor() {
+ this.store = {};
+ }
+
+ clear() {
+ this.store = {};
+ }
+
+ getItem(key) {
+ return this.store[key] || null;
+ }
+
+ setItem(key, value) {
+ this.store[key] = value.toString();
+ }
+
+ removeItem(key) {
+ delete this.store[key];
+ }
+}
+
+export { LocalStorageMock, fakeItem, fakeUser, fakeCartItem, fakeOrder, fakeOrderItem };