summaryrefslogtreecommitdiffstats
path: root/finished-application/frontend/__tests__/Order.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'finished-application/frontend/__tests__/Order.test.js')
-rw-r--r--finished-application/frontend/__tests__/Order.test.js41
1 files changed, 41 insertions, 0 deletions
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('<Order/>', () => {
+ it('Renders loading state', async () => {
+ const wrapper = mount(
+ <MockedProvider mocks={mocks}>
+ <Order id="123" />
+ </MockedProvider>
+ );
+ expect(wrapper.text()).toContain('Loading...');
+ });
+
+ it('Renders the order', async () => {
+ const wrapper = mount(
+ <MockedProvider mocks={mocks}>
+ <Order id="123" />
+ </MockedProvider>
+ );
+ await wait(50);
+ wrapper.update();
+ const order = wrapper.find('div[data-test="order"]');
+ expect(toJSON(order)).toMatchSnapshot();
+ });
+});