diff options
| -rw-r--r-- | frontend/__tests__/AddToCart.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/Cart.test.js | 4 | ||||
| -rw-r--r-- | frontend/__tests__/EditUser.test.js | 6 | ||||
| -rw-r--r-- | frontend/__tests__/Nav.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/Order.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/Pagination.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/PleaseSignIn.test.js | 7 | ||||
| -rw-r--r-- | frontend/__tests__/RemoveFromCart.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/ResetRequest.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/Signup.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/SingleItem.test.js | 2 | ||||
| -rw-r--r-- | frontend/__tests__/TakeMyMoney.test.js | 4 | ||||
| -rw-r--r-- | frontend/jest.setup.js | 13 | ||||
| -rw-r--r-- | frontend/lib/testUtils.js (renamed from frontend/__tests__/testUtils.js) | 0 |
14 files changed, 18 insertions, 32 deletions
diff --git a/frontend/__tests__/AddToCart.test.js b/frontend/__tests__/AddToCart.test.js index c2fc004..5d205f1 100644 --- a/frontend/__tests__/AddToCart.test.js +++ b/frontend/__tests__/AddToCart.test.js @@ -2,7 +2,7 @@ import React from 'react'; import { mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; import AddToCart from '../components/AddToCart'; -import mountOptions from './testUtils'; +import mountOptions from '../lib/testUtils'; describe('<AddtoCart/>', () => { it('renders and matches snapshot', () => { diff --git a/frontend/__tests__/Cart.test.js b/frontend/__tests__/Cart.test.js index 0694a79..9f4e98f 100644 --- a/frontend/__tests__/Cart.test.js +++ b/frontend/__tests__/Cart.test.js @@ -1,11 +1,11 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; -import mountOptions from './testUtils'; +import mountOptions from '../lib/testUtils'; import wait from 'waait'; import Cart from '../components/Cart'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeOrder } from './testUtils'; +import { fakeOrder } from '../lib/testUtils'; import { LOCAL_STATE_QUERY } from '../queries/queries'; const mocks = [ diff --git a/frontend/__tests__/EditUser.test.js b/frontend/__tests__/EditUser.test.js index 7734a4a..2ec0bee 100644 --- a/frontend/__tests__/EditUser.test.js +++ b/frontend/__tests__/EditUser.test.js @@ -2,14 +2,14 @@ import React from 'react'; import { shallow } from 'enzyme'; import toJSON from 'enzyme-to-json'; import EditUser from '../components/EditUser'; -import { mountWithApollo } from './testUtils'; +import { mountWithApollo } from '../lib/testUtils'; import wait from 'waait'; const currentUser = { me: { name: 'Wes Bos', }, - refetch() {}, + refetch() { }, }; describe('<EditUser/>', () => { @@ -43,7 +43,7 @@ describe('<EditUser/>', () => { mutation.client.mutate = jest.fn(); const nameInput = wrapper.find('[name="name"]'); nameInput.simulate('change', { target: { name: 'name', value: 'Scott' } }); - wrapper.find('form').simulate('submit', { preventDefault() {} }); + wrapper.find('form').simulate('submit', { preventDefault() { } }); expect(mutation.client.mutate).toHaveBeenCalledWithVariables({ name: 'Scott' }); }); diff --git a/frontend/__tests__/Nav.test.js b/frontend/__tests__/Nav.test.js index 532ed3e..4989439 100644 --- a/frontend/__tests__/Nav.test.js +++ b/frontend/__tests__/Nav.test.js @@ -3,7 +3,7 @@ import { shallow, mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; import Nav from '../components/Nav'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeUser, fakeOrder } from './mockMang'; +import { fakeUser, fakeOrder } from 'testUtils'; import { CURRENT_USER_QUERY } from '../queries/queries'; import wait from 'waait'; // Mock the router diff --git a/frontend/__tests__/Order.test.js b/frontend/__tests__/Order.test.js index 1f2d691..b9948cf 100644 --- a/frontend/__tests__/Order.test.js +++ b/frontend/__tests__/Order.test.js @@ -4,7 +4,7 @@ import toJSON from 'enzyme-to-json'; import wait from 'waait'; import Order from '../components/Order'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeOrder } from './testUtils'; +import { fakeOrder } from '../lib/testUtils'; import { SINGLE_ORDER_QUERY } from '../queries/queries'; const mocks = [ diff --git a/frontend/__tests__/Pagination.test.js b/frontend/__tests__/Pagination.test.js index 90078b8..4aa590e 100644 --- a/frontend/__tests__/Pagination.test.js +++ b/frontend/__tests__/Pagination.test.js @@ -3,7 +3,7 @@ import { shallow, mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; import Pagination from '../components/Pagination'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeItem } from './testUtils'; +import { fakeItem } from '../lib/testUtils'; import { ALL_ITEMS_QUERY } from '../queries/queries'; const data = { diff --git a/frontend/__tests__/PleaseSignIn.test.js b/frontend/__tests__/PleaseSignIn.test.js index 7a7e275..ea5b6d7 100644 --- a/frontend/__tests__/PleaseSignIn.test.js +++ b/frontend/__tests__/PleaseSignIn.test.js @@ -1,11 +1,10 @@ import React from 'react'; -import { shallow, mount } from 'enzyme'; -import toJSON from 'enzyme-to-json'; +import { mount } from 'enzyme'; +import wait from 'waait'; import PleaseSignIn from '../components/PleaseSignIn'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeUser, fakeOrder } from './mockMang'; +import { fakeUser } from '../lib/testUtils'; import { CURRENT_USER_QUERY } from '../queries/queries'; -import wait from 'waait'; const notSignedInMocks = [ { diff --git a/frontend/__tests__/RemoveFromCart.test.js b/frontend/__tests__/RemoveFromCart.test.js index 8bce7de..a640722 100644 --- a/frontend/__tests__/RemoveFromCart.test.js +++ b/frontend/__tests__/RemoveFromCart.test.js @@ -5,7 +5,7 @@ import { ApolloConsumer } from 'react-apollo'; import { MockedProvider } from 'react-apollo/test-utils'; import wait from 'waait'; import RemoveFromCart from '../components/RemoveFromCart'; -import { mountWithApollo, fakeCartItem, fakeUser } from './testUtils'; +import { mountWithApollo, fakeCartItem, fakeUser } from '../lib/testUtils'; import { CURRENT_USER_QUERY, REMOVE_FROM_CART_MUTATION } from '../queries/queries'; const mocks = [ diff --git a/frontend/__tests__/ResetRequest.test.js b/frontend/__tests__/ResetRequest.test.js index 803f6b6..a08f3bc 100644 --- a/frontend/__tests__/ResetRequest.test.js +++ b/frontend/__tests__/ResetRequest.test.js @@ -2,7 +2,7 @@ import React from 'react'; import { mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; import ResetRequest from '../components/ResetRequest'; -import mountOptions from './testUtils'; +import mountOptions from '../lib/testUtils'; describe('<ResetRequest/>', () => { it('renders and matches snapshot', async () => { diff --git a/frontend/__tests__/Signup.test.js b/frontend/__tests__/Signup.test.js index aa6e1a2..fbeb513 100644 --- a/frontend/__tests__/Signup.test.js +++ b/frontend/__tests__/Signup.test.js @@ -3,7 +3,7 @@ import { mount } from 'enzyme'; import toJSON from 'enzyme-to-json'; import wait from 'waait'; import Signup from '../components/Signup'; -import mountOptions from './testUtils'; +import mountOptions from '../lib/testUtils'; function type(wrapper, name, value) { wrapper.find(`input[name="${name}"]`).simulate('change', { diff --git a/frontend/__tests__/SingleItem.test.js b/frontend/__tests__/SingleItem.test.js index b6b5020..3494f44 100644 --- a/frontend/__tests__/SingleItem.test.js +++ b/frontend/__tests__/SingleItem.test.js @@ -5,7 +5,7 @@ import toJSON from 'enzyme-to-json'; import SingleItem from '../components/SingleItem'; import { SINGLE_ITEM_QUERY } from '../queries/queries'; import { MockedProvider } from 'react-apollo/test-utils'; -import { fakeItem } from './testUtils'; +import { fakeItem } from '../lib/testUtils'; const data = { items: [fakeItem()], diff --git a/frontend/__tests__/TakeMyMoney.test.js b/frontend/__tests__/TakeMyMoney.test.js index 484ca7f..a7d2c98 100644 --- a/frontend/__tests__/TakeMyMoney.test.js +++ b/frontend/__tests__/TakeMyMoney.test.js @@ -5,9 +5,9 @@ import NProgress from 'nprogress'; import TakeMyMoney from '../components/TakeMyMoney'; import Router from 'next/router'; import wait from 'waait'; -import mountOptions from './testUtils'; +import mountOptions from '../lib/testUtils'; -Router.router = { push() {} }; +Router.router = { push() { } }; describe('<TakeMyMoney />', () => { it('renders', async () => { diff --git a/frontend/jest.setup.js b/frontend/jest.setup.js index ad01898..82edfc9 100644 --- a/frontend/jest.setup.js +++ b/frontend/jest.setup.js @@ -2,16 +2,3 @@ import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; configure({ adapter: new Adapter() }); - -expect.extend({ - toHaveBeenCalledWithVariables(received, argument) { - const receivedVariables = received.mock.calls[0][0].variables; - const pass = this.equals(receivedVariables, argument); - const message = () => - `expected ${this.utils.printExpected(argument)} - -to match ${this.utils.printReceived(receivedVariables)}`; - - return { message, pass }; - }, -}); diff --git a/frontend/__tests__/testUtils.js b/frontend/lib/testUtils.js index 6b7132a..6b7132a 100644 --- a/frontend/__tests__/testUtils.js +++ b/frontend/lib/testUtils.js |
