From 8ccb0d93cdc064776454c929e15aa03129be37a3 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 11 May 2018 10:46:24 -0400 Subject: clean up --- frontend/__tests__/CartCount.test.js | 6 +++--- frontend/__tests__/Pagination.test.js | 5 ++--- frontend/__tests__/PleaseSignIn.test.js | 2 +- frontend/__tests__/__snapshots__/Cart.test.js.snap | 4 ++-- frontend/__tests__/__snapshots__/CartCount.test.js.snap | 2 +- .../__tests__/__snapshots__/CreateItem.test.js.snap | 17 +++++++++++++---- frontend/__tests__/__snapshots__/EditUser.test.js.snap | 4 +++- .../__tests__/__snapshots__/Pagination.test.js.snap | 2 ++ .../__tests__/__snapshots__/RemoveFromCart.test.js.snap | 1 + .../__tests__/__snapshots__/ResetRequest.test.js.snap | 4 +++- frontend/__tests__/__snapshots__/Signup.test.js.snap | 4 +++- .../__tests__/__snapshots__/SingleItem.test.js.snap | 3 --- frontend/components/Cart.js | 10 +++++++--- frontend/components/CreateItem.js | 8 +------- frontend/components/Items.js | 9 +-------- frontend/components/Pagination.js | 2 ++ frontend/components/TakeMyMoney.js | 2 +- 17 files changed, 46 insertions(+), 39 deletions(-) (limited to 'frontend') diff --git a/frontend/__tests__/CartCount.test.js b/frontend/__tests__/CartCount.test.js index 6786a86..dcb9ca8 100644 --- a/frontend/__tests__/CartCount.test.js +++ b/frontend/__tests__/CartCount.test.js @@ -5,15 +5,15 @@ import CartCount from '../components/CartCount'; describe('', () => { it('renders okay', () => { - shallow(); + shallow(); }); it('matches snapshot', () => { - const wrapper = shallow(); + const wrapper = shallow(); expect(toJSON(wrapper)).toMatchSnapshot(); }); it('updates via props', () => { - const wrapper = mount(); + const wrapper = mount(); expect(toJSON(wrapper)).toMatchSnapshot(); wrapper.setProps({ count: 10 }); expect(toJSON(wrapper)).toMatchSnapshot(); diff --git a/frontend/__tests__/Pagination.test.js b/frontend/__tests__/Pagination.test.js index 6be60c1..1dbc7b4 100644 --- a/frontend/__tests__/Pagination.test.js +++ b/frontend/__tests__/Pagination.test.js @@ -9,7 +9,8 @@ import { ALL_ITEMS_QUERY } from '../queries/queries'; import Router from 'next/router'; -Router.router = { push() {} }; +// mock the router because there isn't really a router instance +Router.router = { push() {}, prefetch() {} }; function makeMocksFor(length) { return [ @@ -18,14 +19,12 @@ function makeMocksFor(length) { result: { data: { itemsConnection: { - // TODO what are these typenames ???? __typename: 'aggregate', aggregate: { count: length, __typename: 'count', }, }, - // items: [fakeItem()], items: Array.from({ length }, (_, i) => fakeItem({ id: `item${i}` })), }, }, diff --git a/frontend/__tests__/PleaseSignIn.test.js b/frontend/__tests__/PleaseSignIn.test.js index ea5b6d7..5a5a856 100644 --- a/frontend/__tests__/PleaseSignIn.test.js +++ b/frontend/__tests__/PleaseSignIn.test.js @@ -37,7 +37,7 @@ describe('', () => { it('renders sign in dialog to logged out users', async () => { const wrapper = mount( - + diff --git a/frontend/__tests__/__snapshots__/Cart.test.js.snap b/frontend/__tests__/__snapshots__/Cart.test.js.snap index 28011dc..9aeedfd 100644 --- a/frontend/__tests__/__snapshots__/Cart.test.js.snap +++ b/frontend/__tests__/__snapshots__/Cart.test.js.snap @@ -7,7 +7,7 @@ exports[` renders 1`] = ` title="close" >

`; diff --git a/frontend/components/Cart.js b/frontend/components/Cart.js index dbc3e9e..5d68102 100644 --- a/frontend/components/Cart.js +++ b/frontend/components/Cart.js @@ -13,9 +13,13 @@ import CloseButton from './styles/CloseButton'; import SickButton from './styles/SickButton'; const Composed = adopt({ - toggleCart: , - localState: , - currentUser: , + toggleCart: {() => {}}, + localState: {() => {}}, + currentUser: ( + + {() => {}} + + ), }); const Cart = () => ( diff --git a/frontend/components/CreateItem.js b/frontend/components/CreateItem.js index b40932c..0e26330 100644 --- a/frontend/components/CreateItem.js +++ b/frontend/components/CreateItem.js @@ -41,15 +41,9 @@ class CreateItem extends Component { }); }; - // TODO: Problem here - if I refetch page 1, page 2 to infinity are still out of date. I need to refetch all the pages somehow? Or use @connection render() { return ( - + {(createItem, { loading, error }) => (
@@ -41,7 +34,7 @@ class ItemList extends React.Component { skip: this.props.page * perPage - perPage, first: perPage, }} - fetchPolicy={fetchPolicy} + // fetchPolicy="network-only" > {({ data, error, loading }) => { if (loading) { diff --git a/frontend/components/Pagination.js b/frontend/components/Pagination.js index 1432746..cb43a10 100644 --- a/frontend/components/Pagination.js +++ b/frontend/components/Pagination.js @@ -41,6 +41,7 @@ const Pagination = props => ( return ( ( {aggregate.count} Items Total