From b0d25a9ad3cc1df2fcc11ddb84e4603b94520b09 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Mon, 10 Sep 2018 14:29:32 -0400 Subject: almost done --- .../62/frontend/__tests__/Nav.test.js | 76 ++++++++++++++++++ .../62/frontend/__tests__/Pagination.test.js | 89 ++++++++++++++++++++++ .../62/frontend/__tests__/PleaseSignIn.test.js | 51 +++++++++++++ .../__tests__/__snapshots__/Nav.test.js.snap | 37 +++++++++ .../__snapshots__/Pagination.test.js.snap | 67 ++++++++++++++++ stepped-solutions/62/frontend/components/Nav.js | 49 ++++++++++++ .../62/frontend/components/Pagination.js | 67 ++++++++++++++++ 7 files changed, 436 insertions(+) create mode 100755 stepped-solutions/62/frontend/__tests__/Nav.test.js create mode 100755 stepped-solutions/62/frontend/__tests__/Pagination.test.js create mode 100755 stepped-solutions/62/frontend/__tests__/PleaseSignIn.test.js create mode 100755 stepped-solutions/62/frontend/__tests__/__snapshots__/Nav.test.js.snap create mode 100755 stepped-solutions/62/frontend/__tests__/__snapshots__/Pagination.test.js.snap create mode 100755 stepped-solutions/62/frontend/components/Nav.js create mode 100755 stepped-solutions/62/frontend/components/Pagination.js (limited to 'stepped-solutions/62/frontend') diff --git a/stepped-solutions/62/frontend/__tests__/Nav.test.js b/stepped-solutions/62/frontend/__tests__/Nav.test.js new file mode 100755 index 0000000..d30cb39 --- /dev/null +++ b/stepped-solutions/62/frontend/__tests__/Nav.test.js @@ -0,0 +1,76 @@ +import { mount } from 'enzyme'; +import wait from 'waait'; +import toJSON from 'enzyme-to-json'; +import Nav from '../components/Nav'; +import { CURRENT_USER_QUERY } from '../components/User'; +import { MockedProvider } from 'react-apollo/test-utils'; +import { fakeUser, fakeCartItem } from '../lib/testUtils'; + +const notSignedInMocks = [ + { + request: { query: CURRENT_USER_QUERY }, + result: { data: { me: null } }, + }, +]; + +const signedInMocks = [ + { + request: { query: CURRENT_USER_QUERY }, + result: { data: { me: fakeUser() } }, + }, +]; + +const signedInMocksWithCartItems = [ + { + request: { query: CURRENT_USER_QUERY }, + result: { + data: { + me: { + ...fakeUser(), + cart: [fakeCartItem(), fakeCartItem(), fakeCartItem()], + }, + }, + }, + }, +]; + +describe('