diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-24 15:19:21 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-24 15:19:21 -0400 |
| commit | 072eca0e5038a7755ca9b2c94dfe1a0c3f110968 (patch) | |
| tree | a6c54e1503baf665ad0eeaeaad6d2a2b7ba3ba39 /frontend/__tests__/SingleItem.test.js | |
| parent | b294a6fa500b165aae86afbad5fce49a02314b0d (diff) | |
colocate queries and components
Diffstat (limited to 'frontend/__tests__/SingleItem.test.js')
| -rw-r--r-- | frontend/__tests__/SingleItem.test.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/frontend/__tests__/SingleItem.test.js b/frontend/__tests__/SingleItem.test.js index e99facf..aeb8554 100644 --- a/frontend/__tests__/SingleItem.test.js +++ b/frontend/__tests__/SingleItem.test.js @@ -2,10 +2,10 @@ import React from 'react'; import { mount } from 'enzyme'; import wait from 'waait'; import toJSON from 'enzyme-to-json'; -import SingleItem from '../components/SingleItem'; -import { SINGLE_ITEM_QUERY } from '../queries/queries.graphql'; +import SingleItem, { SINGLE_ITEM_QUERY } from '../components/SingleItem'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeItem } from '../lib/testUtils'; +import { fakeItem, fakeUser } from '../lib/testUtils'; +import { CURRENT_USER_QUERY } from '../components/User'; const data = { items: [fakeItem()], @@ -16,9 +16,12 @@ describe('<SingleItem/>', () => { const mocks = [ { request: { query: SINGLE_ITEM_QUERY, variables: { id: '123' } }, - delay: 50, result: { data }, }, + { + request: { query: CURRENT_USER_QUERY }, + result: { data: { me: fakeUser() } }, + }, ]; const wrapper = mount( <MockedProvider mocks={mocks}> @@ -32,9 +35,9 @@ describe('<SingleItem/>', () => { await wait(55); wrapper.update(); // Grab the piece we want - const Item = wrapper.find('[data-test="SingleItem"]'); - // snapshot it! - expect(toJSON(Item)).toMatchSnapshot(); + 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 () => { |
