From f02a5dc73ac4a14c1d641a6ddbfcd2f1bd2ea0b5 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Wed, 2 May 2018 14:45:20 -0400 Subject: TESTS --- frontend/__tests__/Order.test.js | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'frontend/__tests__/Order.test.js') diff --git a/frontend/__tests__/Order.test.js b/frontend/__tests__/Order.test.js index e86af78..b88f9d3 100644 --- a/frontend/__tests__/Order.test.js +++ b/frontend/__tests__/Order.test.js @@ -1,16 +1,42 @@ import React from 'react'; -import { shallow, mount } from 'enzyme'; -import wait from 'waait'; +import { mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; +import wait from 'waait'; import Order from '../components/Order'; -import mountOptions from './mockMang'; +import { MockedProvider } from 'react-apollo/test-utils'; +import { fakeOrder } from './mockMang'; +import { SINGLE_ORDER_QUERY } from '../queries/queries'; + +const mocks = [ + { + request: { query: SINGLE_ORDER_QUERY, variables: { id: '123' } }, + result: { + data: { + order: fakeOrder(), + }, + }, + }, +]; describe('', () => { - it('Renders with Proper Data', async () => { - const wrapper = mount(, mountOptions); - await wait(); + it('Renders loading state', async () => { + const wrapper = mount( + + + + ); + expect(wrapper.text()).toContain('Loading...'); + }); + + it('Renders the order', async () => { + const wrapper = mount( + + + + ); + await wait(15); wrapper.update(); - const order = wrapper.find('[data-test="order"]'); + const order = wrapper.find('div[data-test="order"]'); expect(toJSON(order)).toMatchSnapshot(); }); }); -- cgit v1.3