From 8a5825d52271d712ec7c8348447d433067e13ef2 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 13 Sep 2018 14:18:56 -0400 Subject: DONE --- .../frontend/__tests__/SingleItem.test.js | 67 ---------------------- 1 file changed, 67 deletions(-) delete mode 100644 finished-application/frontend/__tests__/SingleItem.test.js (limited to 'finished-application/frontend/__tests__/SingleItem.test.js') diff --git a/finished-application/frontend/__tests__/SingleItem.test.js b/finished-application/frontend/__tests__/SingleItem.test.js deleted file mode 100644 index 4e9f2b2..0000000 --- a/finished-application/frontend/__tests__/SingleItem.test.js +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import wait from 'waait'; -import toJSON from 'enzyme-to-json'; -import SingleItem, { SINGLE_ITEM_QUERY } from '../components/SingleItem'; -import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeItem, fakeUser } from '../lib/testUtils'; -import { CURRENT_USER_QUERY } from '../components/User'; - -const data = { - items: [fakeItem()], -}; - -describe('', () => { - it('Renders with Proper Data', async () => { - const mocks = [ - { - request: { query: SINGLE_ITEM_QUERY, variables: { id: '123' } }, - result: { data }, - }, - // { - // request: { query: CURRENT_USER_QUERY }, - // result: { data: { me: fakeUser() } }, - // }, - ]; - const wrapper = mount( - - - - ); - // Check for loading state - expect(wrapper.text()).toContain('Loading...'); - - // wait for response and refresh - await wait(55); - wrapper.update(); - // Grab the piece we want - expect(toJSON(wrapper.find('h2'))).toMatchSnapshot(); - expect(toJSON(wrapper.find('img'))).toMatchSnapshot(); - expect(toJSON(wrapper.find('p'))).toMatchSnapshot(); - }); - - it('Errors with a not found Item', async () => { - const mocks = [ - { - request: { query: SINGLE_ITEM_QUERY, variables: { id: '123' } }, - delay: 50, - // we can return data and an error - result: { data, errors: [{ message: 'Item not found!' }] }, - // or just an error! - // error: new Error('offline!'), - }, - ]; - const wrapper = mount( - - - - ); - - // wait for response - await wait(55); - wrapper.update(); - - const Item = wrapper.find('[data-test="graphql-error"]'); - expect(toJSON(Item)).toMatchSnapshot(); - }); -}); -- cgit v1.3