From 2d145b026cfdf54a63bef0b9d6324b6785390307 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 14 Sep 2018 12:18:12 -0400 Subject: move finished folder --- .../frontend/__tests__/Cart.test.js | 39 ++++++++++++++++++++++ 1 file changed, 39 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..b8afc88 --- /dev/null +++ b/finished-application/frontend/__tests__/Cart.test.js @@ -0,0 +1,39 @@ +import { mount } from 'enzyme'; +import wait from 'waait'; +import toJSON from 'enzyme-to-json'; +import { MockedProvider } from 'react-apollo/test-utils'; +import Cart, { LOCAL_STATE_QUERY } from '../components/Cart'; +import { CURRENT_USER_QUERY } from '../components/User'; +import { fakeUser, fakeCartItem } from '../lib/testUtils'; + +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 and matches snappy', async () => { + const wrapper = mount( + + + + ); + await wait(); + wrapper.update(); + expect(toJSON(wrapper.find('header'))).toMatchSnapshot(); + expect(wrapper.find('CartItem')).toHaveLength(1); + }); +}); -- cgit v1.3