summaryrefslogtreecommitdiffstats
path: root/frontend/lib/testUtils.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-05-02 14:59:28 -0400
committerWes Bos <wesbos@gmail.com>2018-05-02 14:59:28 -0400
commitb6b0ee9c2ef43f4eef4df403897bcd8fd9ad2957 (patch)
tree6659fc57d71b84964f96d597c0559ad4f1e0f084 /frontend/lib/testUtils.js
parent6a83ac97ba191e1169aca4a662825bc52624cf12 (diff)
move utils to lib
Diffstat (limited to 'frontend/lib/testUtils.js')
-rw-r--r--frontend/lib/testUtils.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/frontend/lib/testUtils.js b/frontend/lib/testUtils.js
new file mode 100644
index 0000000..6b7132a
--- /dev/null
+++ b/frontend/lib/testUtils.js
@@ -0,0 +1,55 @@
+import casual from 'casual';
+
+// seed it so we get consistent results
+casual.seed(777);
+
+const fakeItem = () => ({
+ __typename: 'Item',
+ id: '123',
+ price: 5000,
+ user: null,
+ image: 'dog-small.jpg',
+ title: 'dogs are best',
+ description: 'dogs',
+ largeImage: 'dog.jpg',
+});
+
+const fakeUser = () => ({
+ __typename: 'User',
+ id: '4234',
+ name: casual.name,
+ email: casual.email,
+ permissions: ['ADMIN'],
+ orders: [],
+ cart: [],
+});
+
+const fakeOrderItem = () => ({
+ id: casual.uuid,
+ image: `${casual.word}.jpg`,
+ title: casual.words(),
+ price: 4234,
+ quantity: 1,
+ description: casual.words(),
+});
+
+const fakeOrder = () => ({
+ __typename: 'Order',
+ id: 'ord123',
+ charge: 'ch_123',
+ total: 40000,
+ items: [fakeOrderItem(), fakeOrderItem()],
+ createdAt: '2018-04 - 06T19: 24: 16.000Z',
+ user: fakeUser(),
+});
+
+const fakeCartItem = overrides => ({
+ __typename: 'CartItem',
+ id: 'omg123',
+ quantity: 3,
+ item: fakeItem(),
+ user: fakeUser(),
+ ...overrides,
+});
+
+export { fakeItem, fakeUser, fakeCartItem, fakeOrder, fakeOrderItem };