From b1600adec47a04f60e1da07d94a3ed3906ff5aee Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 14 Jun 2018 16:44:21 -0400 Subject: starter files --- .../frontend/__tests__/Order.test.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 finished-application/frontend/__tests__/Order.test.js (limited to 'finished-application/frontend/__tests__/Order.test.js') diff --git a/finished-application/frontend/__tests__/Order.test.js b/finished-application/frontend/__tests__/Order.test.js new file mode 100644 index 0000000..f3a4f06 --- /dev/null +++ b/finished-application/frontend/__tests__/Order.test.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import toJSON from 'enzyme-to-json'; +import wait from 'waait'; +import { MockedProvider } from 'react-apollo/test-utils'; +import Order, { SINGLE_ORDER_QUERY } from '../components/Order'; +import { fakeOrder } from '../lib/testUtils'; + +const mocks = [ + { + request: { query: SINGLE_ORDER_QUERY, variables: { id: '123' } }, + result: { + data: { + order: fakeOrder(), + }, + }, + }, +]; + +describe('', () => { + it('Renders loading state', async () => { + const wrapper = mount( + + + + ); + expect(wrapper.text()).toContain('Loading...'); + }); + + it('Renders the order', async () => { + const wrapper = mount( + + + + ); + await wait(50); + wrapper.update(); + const order = wrapper.find('div[data-test="order"]'); + expect(toJSON(order)).toMatchSnapshot(); + }); +}); -- cgit v1.3