summaryrefslogtreecommitdiffstats
path: root/finished-application/frontend/__tests__/Cart.test.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-06-14 16:44:21 -0400
committerWes Bos <wesbos@gmail.com>2018-06-14 16:44:21 -0400
commitb1600adec47a04f60e1da07d94a3ed3906ff5aee (patch)
tree828f786da6806d7237ee5cbc5df61e552353b85b /finished-application/frontend/__tests__/Cart.test.js
parenta95e08cd2dd5d7ec0a0412adae02515a5f9cec4f (diff)
starter files
Diffstat (limited to 'finished-application/frontend/__tests__/Cart.test.js')
-rw-r--r--finished-application/frontend/__tests__/Cart.test.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/finished-application/frontend/__tests__/Cart.test.js b/finished-application/frontend/__tests__/Cart.test.js
new file mode 100644
index 0000000..255183e
--- /dev/null
+++ b/finished-application/frontend/__tests__/Cart.test.js
@@ -0,0 +1,46 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import toJSON from 'enzyme-to-json';
+import mountOptions from '../lib/testUtils';
+import wait from 'waait';
+import Cart from '../components/Cart';
+import { MockedProvider } from 'react-apollo/test-utils';
+import { fakeCartItem, fakeUser } from '../lib/testUtils';
+import { CURRENT_USER_QUERY } from '../components/User';
+import { LOCAL_STATE_QUERY } from '../components/Cart';
+
+const mocks = [
+ {
+ request: { query: CURRENT_USER_QUERY },
+ result: {
+ data: {
+ me: {
+ ...fakeUser(),
+ cart: [fakeCartItem()],
+ },
+ },
+ },
+ },
+ {
+ request: { query: LOCAL_STATE_QUERY },
+ result: {
+ data: {
+ cartOpen: true,
+ },
+ },
+ },
+];
+
+describe('<Cart/>', () => {
+ it('renders', async () => {
+ const wrapper = mount(
+ <MockedProvider mocks={mocks}>
+ <Cart />
+ </MockedProvider>
+ );
+ await wait();
+ wrapper.update();
+ expect(toJSON(wrapper.find('header'))).toMatchSnapshot();
+ expect(wrapper.find('CartItem')).toHaveLength(1);
+ });
+});