summaryrefslogtreecommitdiffstats
path: root/frontend/__tests__/SingleItem.test.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-04-17 16:51:09 -0400
committerWes Bos <wesbos@gmail.com>2018-04-17 16:51:09 -0400
commit54dd0e29830f04c9055863fb0449ee4fc2ab0689 (patch)
tree920fc79aea7624f0480603ba716aa38358dbc5ab /frontend/__tests__/SingleItem.test.js
parent4f907fc051a9863e3cbea249b33a71009551f482 (diff)
these tests are on fireee but the bad kind
Diffstat (limited to 'frontend/__tests__/SingleItem.test.js')
-rw-r--r--frontend/__tests__/SingleItem.test.js40
1 files changed, 24 insertions, 16 deletions
diff --git a/frontend/__tests__/SingleItem.test.js b/frontend/__tests__/SingleItem.test.js
index e39431d..313784e 100644
--- a/frontend/__tests__/SingleItem.test.js
+++ b/frontend/__tests__/SingleItem.test.js
@@ -1,23 +1,31 @@
import React from 'react';
-import { shallow } from 'enzyme';
+import { shallow, mount } from 'enzyme';
+import wait from 'waait';
import toJSON from 'enzyme-to-json';
-import { SingleItem } from '../components/SingleItem';
+import SingleItem from '../components/SingleItem';
+import { ApolloProvider } from 'react-apollo';
+import mockClient from './mockMang';
+import { SINGLE_ITEM_QUERY } from '../queries/queries';
-const wait = amount => new Promise(resolve => setTimeout(resolve, amount));
+describe('<SingleItem/>', () => {
+ it('Renders with Proper Data', async () => {
+ const wrapper = mount(
+ <ApolloProvider client={mockClient.client}>
+ <SingleItem id="123" />
+ </ApolloProvider>
+ );
+ await wait();
+ wrapper.update();
-const findItem = {
- items: [
- {
- largeImage: 'dog.jpg',
- title: 'Sneakers',
- description: 'A cool set of shoes',
- },
- ],
-};
+ const Item = wrapper.find('[data-test="SingleItem"]');
+ expect(toJSON(Item)).toMatchSnapshot();
+ });
-describe('<SingleItem/>', () => {
- it('renders', () => {
- const wrapper = shallow(<SingleItem findItem={findItem} />);
- expect(toJSON(wrapper)).toMatchSnapshot();
+ it('Errors with a not found Item', async () => {
+ const wrapper = mount(
+ <ApolloProvider client={mockClient.client}>
+ <SingleItem id="123" />
+ </ApolloProvider>
+ );
});
});