From b1600adec47a04f60e1da07d94a3ed3906ff5aee Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 14 Jun 2018 16:44:21 -0400 Subject: starter files --- .../frontend/__tests__/Cart.test.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 finished-application/frontend/__tests__/Cart.test.js (limited to 'finished-application/frontend/__tests__/Cart.test.js') 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('', () => { + it('renders', async () => { + const wrapper = mount( + + + + ); + await wait(); + wrapper.update(); + expect(toJSON(wrapper.find('header'))).toMatchSnapshot(); + expect(wrapper.find('CartItem')).toHaveLength(1); + }); +}); -- cgit v1.3