summaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/__tests__/Order.test.js2
-rw-r--r--frontend/__tests__/ResetRequest.test.js7
-rw-r--r--frontend/jest.setup.js13
-rw-r--r--frontend/package.json6
4 files changed, 20 insertions, 8 deletions
diff --git a/frontend/__tests__/Order.test.js b/frontend/__tests__/Order.test.js
index 6bcf0b9..e86af78 100644
--- a/frontend/__tests__/Order.test.js
+++ b/frontend/__tests__/Order.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { mount } from 'enzyme';
+import { shallow, mount } from 'enzyme';
import wait from 'waait';
import toJSON from 'enzyme-to-json';
import Order from '../components/Order';
diff --git a/frontend/__tests__/ResetRequest.test.js b/frontend/__tests__/ResetRequest.test.js
index 6d8d99f..638a2aa 100644
--- a/frontend/__tests__/ResetRequest.test.js
+++ b/frontend/__tests__/ResetRequest.test.js
@@ -4,6 +4,7 @@ import toJSON from 'enzyme-to-json';
import { ApolloProvider } from 'react-apollo';
import ResetRequest from '../components/ResetRequest';
import mountOptions from './mockMang';
+import wait from 'waait';
describe('<ResetRequest/>', () => {
it('renders and matches snapshot', async () => {
@@ -21,9 +22,9 @@ describe('<ResetRequest/>', () => {
mutation.client.mutate = jest.fn();
mutation.forceUpdate();
wrapper.find('Form').simulate('submit');
- expect(mutation.client.mutate.mock.calls[0][0].variables).toEqual({
- email: 'wesbos@gmail.com',
- });
+
+ expect(mutation.client.mutate).toBeCalledWithVariables({ email: 'wesbos@gmail.com' });
+
expect(toJSON(wrapper)).toMatchSnapshot();
});
diff --git a/frontend/jest.setup.js b/frontend/jest.setup.js
index 82edfc9..1783f17 100644
--- a/frontend/jest.setup.js
+++ b/frontend/jest.setup.js
@@ -2,3 +2,16 @@ import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
+
+expect.extend({
+ toBeCalledWithVariables(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/package.json b/frontend/package.json
index 977c015..28c97a5 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -45,9 +45,7 @@
},
"//": "This is out babel config, I prefer this over a .babelrc file",
"jest": {
- "setupFiles": [
- "<rootDir>/jest.setup.js"
- ],
+ "setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
"testPathIgnorePatterns": [
"<rootDir>/.next/",
"<rootDir>/node_modules/"
@@ -97,4 +95,4 @@
}
}
}
-}
+} \ No newline at end of file