diff --git a/.eslintrc b/.eslintrc
index 38dae815f..84535ebf2 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -58,6 +58,7 @@
"react/jsx-no-undef": 0,
"react/no-multi-comp": 0,
"react/jsx-one-expression-per-line": 0,
+ "react/jsx-fragments": 0,
},
},
],
diff --git a/.travis.yml b/.travis.yml
index 09465f811..a968cc3b3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -75,6 +75,7 @@ matrix:
- node_js: "6"
env: REACT=0.13
env:
+ - REACT=16.9
- REACT=16.8
- REACT=16.7
- REACT=16.6
diff --git a/docs/api/ReactWrapper/everyWhere.md b/docs/api/ReactWrapper/everyWhere.md
index b185d938b..f8e972c59 100644
--- a/docs/api/ReactWrapper/everyWhere.md
+++ b/docs/api/ReactWrapper/everyWhere.md
@@ -25,9 +25,9 @@ const wrapper = mount((
{function Foo() { /* hi */ }}
{
}
- {arrow => arrow('function')}
+ {(arrow) => arrow('function')}
{[1, 2, NaN]}
{function (anonymous) {}}
{{ a: 'b' }}
diff --git a/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx b/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx
index efc05a415..b691fb59d 100644
--- a/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx
+++ b/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx
@@ -115,7 +115,7 @@ describe('RSTTraversal', () => {
));
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 3);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB]);
});
@@ -141,7 +141,7 @@ describe('RSTTraversal', () => {
));
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 5);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB, divC, divD]);
});
@@ -160,7 +160,7 @@ describe('RSTTraversal', () => {
));
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 3);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB]);
});
@@ -186,7 +186,7 @@ describe('RSTTraversal', () => {
));
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 5);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB, divC, divD]);
});
@@ -205,7 +205,7 @@ describe('RSTTraversal', () => {
));
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 3);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB]);
});
@@ -231,7 +231,7 @@ describe('RSTTraversal', () => {
));
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 5);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB, divC, divD]);
});
@@ -275,7 +275,7 @@ describe('RSTTraversal', () => {
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 3);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB]);
});
@@ -298,7 +298,7 @@ describe('RSTTraversal', () => {
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 5);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB, divC, divD]);
});
@@ -317,7 +317,7 @@ describe('RSTTraversal', () => {
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 3);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB]);
});
@@ -340,7 +340,7 @@ describe('RSTTraversal', () => {
treeForEach(node, spy);
expect(spy).to.have.property('callCount', 5);
- const nodes = spy.args.map(arg => arg[0]);
+ const nodes = spy.args.map((arg) => arg[0]);
expect(nodes).to.deep.equal([node, divA, divB, divC, divD]);
});
});
@@ -397,8 +397,8 @@ describe('RSTTraversal', () => {
});
it('filters for truthiness', () => {
- expect(treeFilter(tree, node => node.type === 'nav').length).to.equal(1);
- expect(treeFilter(tree, node => node.type === 'button').length).to.equal(2);
+ expect(treeFilter(tree, (node) => node.type === 'nav').length).to.equal(1);
+ expect(treeFilter(tree, (node) => node.type === 'button').length).to.equal(2);
});
});
diff --git a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
index 007a8de7b..7f7e73894 100644
--- a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
@@ -283,9 +283,9 @@ describeWithDOM('mount', () => {
function Component() {
return (
- {value1 => (
+ {(value1) => (
- {value2 => (
+ {(value2) => (
Value 1: {value1}; Value 2: {value2}
)}
@@ -367,7 +367,7 @@ describeWithDOM('mount', () => {
const Bar = () => null;
wrap()
.withConsoleThrows()
- .withOverride(() => getAdapter(), 'isValidElementType', () => val => val === Foo)
+ .withOverride(() => getAdapter(), 'isValidElementType', () => (val) => val === Foo)
.it('with isValidElementType defined on the Adapter', () => {
expect(() => {
mount();
@@ -499,7 +499,7 @@ describeWithDOM('mount', () => {
class Foo extends React.Component {
render() {
return (
- {value => {value}}
+ {(value) => {value}}
);
}
}
@@ -512,7 +512,7 @@ describeWithDOM('mount', () => {
it('can render a as the root', () => {
const wrapper = mount(
- {value => {value}
}
+ {(value) => {value}
}
,
);
expect(wrapper.text()).to.equal('cool');
@@ -523,12 +523,12 @@ describeWithDOM('mount', () => {
it('can render a as the root', () => {
const wrapper = mount(
- {value => {value}
},
+ {(value) => {value}
},
);
expect(wrapper.text()).to.equal('hello');
wrapper.setProps({
- children: value => Value is: {value}
,
+ children: (value) => Value is: {value}
,
});
expect(wrapper.text()).to.equal('Value is: hello');
});
@@ -1541,6 +1541,14 @@ describeWithDOM('mount', () => {
});
describe('lifecycle methods', () => {
+ const errorToThrow = new EvalError('threw an error!');
+ // in React 16.0 - 16.2 and 16.9+, and some older nodes, the actual error thrown isn't reported.
+ const reactError = new Error('An error was thrown inside one of your components, but React doesn\'t know what it was. This is likely due to browser flakiness. React does its best to preserve the "Pause on exceptions" behavior of the DevTools, which requires some DEV-mode only tricks. It\'s possible that these don\'t work in your browser. Try triggering the error in production mode, or switching to a modern browser. If you suspect that this is actually an issue with React, please file an issue.');
+ const properErrorMessage = (error) => error instanceof Error && (
+ error.message === errorToThrow.message
+ || error.message === reactError.message
+ );
+
describeIf(is('>= 16.3'), 'getDerivedStateFromProps', () => {
let spy;
@@ -1794,14 +1802,6 @@ describeWithDOM('mount', () => {
describeIf(is('>= 16'), 'componentDidCatch', () => {
describe('errors inside an error boundary', () => {
- const errorToThrow = new EvalError('threw an error!');
- // in React 16.0 - 16.2, and some older nodes, the actual error thrown isn't reported.
- const reactError = new Error('An error was thrown inside one of your components, but React doesn\'t know what it was. This is likely due to browser flakiness. React does its best to preserve the "Pause on exceptions" behavior of the DevTools, which requires some DEV-mode only tricks. It\'s possible that these don\'t work in your browser. Try triggering the error in production mode, or switching to a modern browser. If you suspect that this is actually an issue with React, please file an issue.');
- const properErrorMessage = error => error instanceof Error && (
- error.message === errorToThrow.message
- || error.message === reactError.message
- );
-
const hasFragments = is('>= 16.2');
const MaybeFragment = hasFragments ? Fragment : 'main';
@@ -1972,8 +1972,6 @@ describeWithDOM('mount', () => {
describeIf(is('>= 16.6'), 'getDerivedStateFromError', () => {
describe('errors inside an error boundary', () => {
- const errorToThrow = new EvalError('threw an error!');
-
function Thrower({ throws }) {
if (throws) {
throw errorToThrow;
@@ -2035,7 +2033,7 @@ describeWithDOM('mount', () => {
mount();
expect(true).to.equal(false, 'this line should not be reached');
} catch (error) {
- expect(error).to.equal(errorToThrow);
+ expect(error).to.satisfy(properErrorMessage);
}
});
});
@@ -2099,7 +2097,7 @@ describeWithDOM('mount', () => {
expect(spy.args).to.be.an('array').and.have.lengthOf(1);
const [[actualError]] = spy.args;
- expect(actualError).to.equal(errorToThrow);
+ expect(actualError).to.satisfy(properErrorMessage);
});
it('works when the root is an SFC', () => {
@@ -2116,14 +2114,12 @@ describeWithDOM('mount', () => {
expect(spy.args).to.be.an('array').and.have.lengthOf(1);
const [[actualError]] = spy.args;
- expect(actualError).to.equal(errorToThrow);
+ expect(actualError).to.satisfy(properErrorMessage);
});
});
});
describeIf(is('>= 16.6'), 'getDerivedStateFromError and componentDidCatch combined', () => {
-
- const errorToThrow = new EvalError('threw an error!');
const expectedInfo = {
componentStack: `
in Thrower (created by ErrorBoundary)
@@ -2203,12 +2199,13 @@ describeWithDOM('mount', () => {
wrapper.setState({ throws: true });
expect(lifecycleSpy).to.have.property('callCount', 4);
- expect(lifecycleSpy.args).to.deep.equal([
- ['render'],
- ['getDerivedStateFromError', errorToThrow],
- ['render'],
- ['componentDidCatch', errorToThrow, expectedInfo],
- ]);
+ const [first, second, third, fourth] = lifecycleSpy.args;
+ expect(first).to.deep.equal(['render']);
+ expect(second).to.satisfy(([name, error, ...rest]) => name === 'getDerivedStateFromError'
+ && properErrorMessage(error)
+ && rest.length === 0);
+ expect(third).to.deep.equal(['render']);
+ expect(fourth).to.satisfy(([name, error, info]) => name === 'componentDidCatch' && properErrorMessage(error) && isEqual(info, expectedInfo));
expect(stateSpy).to.have.property('callCount', 1);
expect(stateSpy.args).to.deep.equal([
@@ -2313,14 +2310,20 @@ describeWithDOM('mount', () => {
spy.resetHistory();
- expect(() => wrapper.setState({ throws: true })).to.throw(errorToThrow);
+ try {
+ wrapper.setState({ throws: true });
+ expect('should never get here').to.equal(false);
+ } catch (e) {
+ expect(e).to.satisfy(properErrorMessage);
+ }
expect(spy).to.have.property('callCount', 3);
- expect(spy.args).to.deep.equal([
- ['render'],
- ['getDerivedStateFromError', errorToThrow],
- ['render'],
- ]);
+ const [first, second, third] = spy.args;
+ expect(first).to.deep.equal(['render']);
+ expect(second).to.satisfy(([name, arg, ...rest]) => name === 'getDerivedStateFromError'
+ && properErrorMessage(arg)
+ && rest.length === 0);
+ expect(third).to.deep.equal(['render']);
});
it('renders again on simulated error', () => {
diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
index 25e2fb2be..946932d6f 100644
--- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
@@ -296,9 +296,9 @@ describe('shallow', () => {
function Component() {
return (
- {value1 => (
+ {(value1) => (
- {value2 => (
+ {(value2) => (
Value 1: {value1}; Value 2: {value2}
)}
@@ -376,7 +376,7 @@ describe('shallow', () => {
const Bar = () => null;
wrap()
.withConsoleThrows()
- .withOverride(() => getAdapter(), 'isValidElementType', () => val => val === Foo)
+ .withOverride(() => getAdapter(), 'isValidElementType', () => (val) => val === Foo)
.it('with isValidElementType defined on the Adapter', () => {
expect(() => {
shallow();
@@ -436,7 +436,7 @@ describe('shallow', () => {
render() {
return (
- {value => {value}}
+ {(value) => {value}}
);
}
@@ -480,7 +480,7 @@ describe('shallow', () => {
const wrapper = shallow(
- {value => {value}
}
+ {(value) => {value}
}
,
);
@@ -495,7 +495,7 @@ describe('shallow', () => {
const wrapper = shallow(
- {value => {value}
}
+ {(value) => {value}
}
,
);
@@ -511,7 +511,7 @@ describe('shallow', () => {
it('can be rendered as the root', () => {
const wrapper = shallow(
- {value => {value}}
+ {(value) => {value}}
,
);
expect(wrapper.debug()).to.eql(`
@@ -524,10 +524,10 @@ describe('shallow', () => {
it('supports changing the children', () => {
const wrapper = shallow(
- {value => {value}}
+ {(value) => {value}}
,
);
- wrapper.setProps({ children: value => Changed: {value} });
+ wrapper.setProps({ children: (value) => Changed: {value} });
expect(wrapper.find(DivRenderer).dive().text()).to.eql('Changed: cool');
});
});
@@ -545,7 +545,7 @@ describe('shallow', () => {
render() {
return (
- {value => {value}}
+ {(value) => {value}}
);
}
diff --git a/packages/enzyme-test-suite/test/Utils-spec.jsx b/packages/enzyme-test-suite/test/Utils-spec.jsx
index a6e2e76ec..c6a2a27cb 100644
--- a/packages/enzyme-test-suite/test/Utils-spec.jsx
+++ b/packages/enzyme-test-suite/test/Utils-spec.jsx
@@ -733,11 +733,11 @@ describe('Utils', () => {
];
it('returns true when renderedDive receives nodes that render validEmpty values', () => {
- emptyNodetestData.forEach(node => expect(renderedDive(node)).to.equal(true));
+ emptyNodetestData.forEach((node) => expect(renderedDive(node)).to.equal(true));
});
it('returns false when renderedDive receives nodes that render non-valid empty values', () => {
- nonEmptyNodeData.forEach(node => expect(renderedDive(node)).to.equal(false));
+ nonEmptyNodeData.forEach((node) => expect(renderedDive(node)).to.equal(false));
});
});
diff --git a/packages/enzyme-test-suite/test/_helpers/react-compat.js b/packages/enzyme-test-suite/test/_helpers/react-compat.js
index a5d06b2f9..f265092fd 100644
--- a/packages/enzyme-test-suite/test/_helpers/react-compat.js
+++ b/packages/enzyme-test-suite/test/_helpers/react-compat.js
@@ -18,6 +18,7 @@ let Fragment;
let StrictMode;
let AsyncMode;
let ConcurrentMode;
+let createRoot;
let Profiler;
let PureComponent;
let Suspense;
@@ -83,7 +84,9 @@ if (is('^16.3.0-0')) {
AsyncMode = null;
}
-if (is('^16.4.0-0')) {
+if (is('^16.9.0-0')) {
+ ({ Profiler } = require('react'));
+} else if (is('^16.4.0-0')) {
({
unstable_Profiler: Profiler,
} = require('react'));
@@ -93,18 +96,32 @@ if (is('^16.4.0-0')) {
if (is('^16.6.0-0')) {
({
- unstable_ConcurrentMode: ConcurrentMode,
Suspense,
lazy,
memo,
} = require('react'));
} else {
- ConcurrentMode = null;
Suspense = null;
lazy = null;
memo = null;
}
+if (is('^16.6.0-0') && !is('^16.9.0-0')) {
+ ({
+ unstable_ConcurrentMode: ConcurrentMode,
+ } = require('react'));
+} else {
+ ConcurrentMode = null;
+}
+
+if (is('^16.9.0-0')) {
+ ({
+ unstable_createRoot: createRoot,
+ } = require('react'));
+} else {
+ createRoot = null;
+}
+
if (is('^16.8.0-0')) {
({
useCallback,
@@ -145,6 +162,7 @@ export {
createPortal,
createContext,
createRef,
+ createRoot,
forwardRef,
Fragment,
StrictMode,
diff --git a/packages/enzyme-test-suite/test/_helpers/realArrowFunction.js b/packages/enzyme-test-suite/test/_helpers/realArrowFunction.js
index 8e004fd3e..f6d4928ab 100644
--- a/packages/enzyme-test-suite/test/_helpers/realArrowFunction.js
+++ b/packages/enzyme-test-suite/test/_helpers/realArrowFunction.js
@@ -2,5 +2,5 @@ try {
// eslint-disable-next-line global-require
module.exports = require('./untranspiledArrowFunction');
} catch (e) {
- module.exports = x => () => x;
+ module.exports = (x) => () => x;
}
diff --git a/packages/enzyme-test-suite/test/_helpers/selectors.js b/packages/enzyme-test-suite/test/_helpers/selectors.js
index a16b80c39..1b313b974 100644
--- a/packages/enzyme-test-suite/test/_helpers/selectors.js
+++ b/packages/enzyme-test-suite/test/_helpers/selectors.js
@@ -1,3 +1,3 @@
-export const getElementPropSelector = prop => x => x.props[prop];
+export const getElementPropSelector = (prop) => (x) => x.props[prop];
-export const getWrapperPropSelector = prop => x => x.prop(prop);
+export const getWrapperPropSelector = (prop) => (x) => x.prop(prop);
diff --git a/packages/enzyme-test-suite/test/_helpers/untranspiledArrowFunction.js b/packages/enzyme-test-suite/test/_helpers/untranspiledArrowFunction.js
index 5a86b7ae6..67ef1adc1 100644
--- a/packages/enzyme-test-suite/test/_helpers/untranspiledArrowFunction.js
+++ b/packages/enzyme-test-suite/test/_helpers/untranspiledArrowFunction.js
@@ -1,3 +1,3 @@
// this file is ignored in babelrc, specifically so that tests will be able to run
// on a real arrow function that lacks a .prototype
-module.exports = x => () => x;
+module.exports = (x) => () => x;
diff --git a/packages/enzyme-test-suite/test/adapter-utils-spec.jsx b/packages/enzyme-test-suite/test/adapter-utils-spec.jsx
index 80815e321..cc0246af8 100644
--- a/packages/enzyme-test-suite/test/adapter-utils-spec.jsx
+++ b/packages/enzyme-test-suite/test/adapter-utils-spec.jsx
@@ -224,20 +224,20 @@ describe('enzyme-adapter-utils', () => {
);
it('finds an element in the render tree using a predicate', () => {
- expect(findElement(tree, node => node.type === Target)).to.eql(target);
+ expect(findElement(tree, (node) => node.type === Target)).to.eql(target);
});
it('returns undefined if the element cannot be found', () => {
- expect(findElement(tree, node => node.type === Unfound)).to.equal(undefined);
+ expect(findElement(tree, (node) => node.type === Unfound)).to.equal(undefined);
});
it('returns undefined if some non-element is passed', () => {
- expect(findElement({}, node => node.type === Target)).to.equal(undefined);
+ expect(findElement({}, (node) => node.type === Target)).to.equal(undefined);
});
});
describe('getNodeFromRootFinder', () => {
- const isCustomComponent = component => typeof component === 'function';
+ const isCustomComponent = (component) => typeof component === 'function';
class Target extends React.Component { render() { return null; } }
class WrappingComponent extends React.Component { render() { return null; } }
diff --git a/packages/enzyme-test-suite/test/selector-spec.jsx b/packages/enzyme-test-suite/test/selector-spec.jsx
index c3f026ce3..769f719d4 100644
--- a/packages/enzyme-test-suite/test/selector-spec.jsx
+++ b/packages/enzyme-test-suite/test/selector-spec.jsx
@@ -298,7 +298,7 @@ describe('selectors', () => {
expect(wrapper.find('.to-find')).to.have.lengthOf(3);
const toFind = wrapper.find('.to-find + .sibling');
expect(toFind).to.have.lengthOf(2);
- toFind.map(found => expect(found.text()).to.equal('Adjacent'));
+ toFind.map((found) => expect(found.text()).to.equal('Adjacent'));
});
it('simple general siblings', () => {
@@ -336,7 +336,7 @@ describe('selectors', () => {
const spans = wrapper.find('span');
const siblings = wrapper.find('span ~ span');
expect(spans.length - 2).to.equal(siblings.length);
- siblings.map(sibling => expect(sibling.text()).to.not.equal('Top'));
+ siblings.map((sibling) => expect(sibling.text()).to.not.equal('Top'));
});
it('handles using general siblings on root', () => {
diff --git a/packages/enzyme-test-suite/test/shared/hooks/custom.jsx b/packages/enzyme-test-suite/test/shared/hooks/custom.jsx
index 8aad509d3..4a70358a1 100644
--- a/packages/enzyme-test-suite/test/shared/hooks/custom.jsx
+++ b/packages/enzyme-test-suite/test/shared/hooks/custom.jsx
@@ -20,8 +20,8 @@ export default function describeCustomHooks({
describe('custom hook : useCounter', () => {
function useCounter({ initialCount = 0, step = 1 } = {}) {
const [count, setCount] = useState(initialCount);
- const increment = () => setCount(c => c + step);
- const decrement = () => setCount(c => c - step);
+ const increment = () => setCount((c) => c + step);
+ const decrement = () => setCount((c) => c - step);
return { count, increment, decrement };
}
// testing custom hooks with renderProps
diff --git a/packages/enzyme-test-suite/test/shared/hooks/useCallback.jsx b/packages/enzyme-test-suite/test/shared/hooks/useCallback.jsx
index dfdbbb0df..19a5cdc40 100644
--- a/packages/enzyme-test-suite/test/shared/hooks/useCallback.jsx
+++ b/packages/enzyme-test-suite/test/shared/hooks/useCallback.jsx
@@ -21,14 +21,14 @@ export default function describeUseCallback({
}
function ComponentUsingCallbackHook({ onChange }) {
- const callback = useCallback(value => onChange(value), [onChange]);
+ const callback = useCallback((value) => onChange(value), [onChange]);
return (
);
}
function ComponentUsingCallbackHookWithRelatedProp({ onChange, relatedProp }) {
- const callback = useCallback(value => onChange(value), [onChange, relatedProp]);
+ const callback = useCallback((value) => onChange(value), [onChange, relatedProp]);
return (
);
diff --git a/packages/enzyme-test-suite/test/shared/hooks/useDebugValue.jsx b/packages/enzyme-test-suite/test/shared/hooks/useDebugValue.jsx
index 479102ed1..7cb0323ea 100644
--- a/packages/enzyme-test-suite/test/shared/hooks/useDebugValue.jsx
+++ b/packages/enzyme-test-suite/test/shared/hooks/useDebugValue.jsx
@@ -22,7 +22,7 @@ export default function describeUseDebugValue({
return ({value}
);
}
- function ComponentUsingDebugValueAndCallback({ value, fn = x => `debug value: ${x}` }) {
+ function ComponentUsingDebugValueAndCallback({ value, fn = (x) => `debug value: ${x}` }) {
useDebugValue(value, fn);
return ({value}
);
diff --git a/packages/enzyme-test-suite/test/shared/hooks/useEffect.jsx b/packages/enzyme-test-suite/test/shared/hooks/useEffect.jsx
index 76ad1f11e..c9e95e38f 100644
--- a/packages/enzyme-test-suite/test/shared/hooks/useEffect.jsx
+++ b/packages/enzyme-test-suite/test/shared/hooks/useEffect.jsx
@@ -149,7 +149,7 @@ export default function describeUseEffect({
});
describe('on componentDidUpdate & componentDidMount', () => {
- const expectedCountString = x => `You clicked ${x} times`;
+ const expectedCountString = (x) => `You clicked ${x} times`;
let setDocumentTitle;
function ClickCounterPage() {
diff --git a/packages/enzyme-test-suite/test/shared/hooks/useReducer.jsx b/packages/enzyme-test-suite/test/shared/hooks/useReducer.jsx
index 6e0670858..987b584a9 100644
--- a/packages/enzyme-test-suite/test/shared/hooks/useReducer.jsx
+++ b/packages/enzyme-test-suite/test/shared/hooks/useReducer.jsx
@@ -40,7 +40,7 @@ export default function describeUseReducer({
- {state.map(text => (
+ {state.map((text) => (
{text}
))}
diff --git a/packages/enzyme-test-suite/test/shared/methods/children.jsx b/packages/enzyme-test-suite/test/shared/methods/children.jsx
index dc32de08d..7ef00f03b 100644
--- a/packages/enzyme-test-suite/test/shared/methods/children.jsx
+++ b/packages/enzyme-test-suite/test/shared/methods/children.jsx
@@ -82,7 +82,7 @@ export default function describeChildren({
return (
- {items.map(x => x)}
+ {items.map((x) => x)}
);
}
@@ -120,7 +120,7 @@ export default function describeChildren({
const Foo = ({ items }) => (
- {items.map(x => x)}
+ {items.map((x) => x)}
);
@@ -153,7 +153,7 @@ export default function describeChildren({
const wrapper = Wrap();
const children = wrapper.children();
- const textNodes = children.map(x => x.text());
+ const textNodes = children.map((x) => x.text());
const expectedShallowNodes = ['Foo', ' Bar ', 'Foo', ' Bar ', 'Foo'];
const expectedTextNodes = isShallow ? expectedShallowNodes : [expectedShallowNodes.join('')];
expect(textNodes).to.eql(expectedTextNodes);
@@ -165,7 +165,7 @@ export default function describeChildren({
const { children } = this.props;
const wrappedChildren = React.Children.map(
children,
- child => child && {child},
+ (child) => child && {child},
);
const justifiedChildren = [];
@@ -188,7 +188,7 @@ export default function describeChildren({
));
- expect(wrapper.children().map(x => x.debug())).to.eql([
+ expect(wrapper.children().map((x) => x.debug())).to.eql([
`
foo
diff --git a/packages/enzyme-test-suite/test/shared/methods/everyWhere.jsx b/packages/enzyme-test-suite/test/shared/methods/everyWhere.jsx
index f65dffbb7..2dee9d32f 100644
--- a/packages/enzyme-test-suite/test/shared/methods/everyWhere.jsx
+++ b/packages/enzyme-test-suite/test/shared/methods/everyWhere.jsx
@@ -14,9 +14,9 @@ export default function describeEveryWhere({
));
const foo = wrapper.find('.foo');
- expect(foo.everyWhere(n => n.hasClass('foo'))).to.equal(true);
- expect(foo.everyWhere(n => n.hasClass('qoo'))).to.equal(false);
- expect(foo.everyWhere(n => n.hasClass('bar'))).to.equal(false);
+ expect(foo.everyWhere((n) => n.hasClass('foo'))).to.equal(true);
+ expect(foo.everyWhere((n) => n.hasClass('qoo'))).to.equal(false);
+ expect(foo.everyWhere((n) => n.hasClass('bar'))).to.equal(false);
});
});
}
diff --git a/packages/enzyme-test-suite/test/shared/methods/findWhere.jsx b/packages/enzyme-test-suite/test/shared/methods/findWhere.jsx
index 92e628bf4..a14ab2743 100644
--- a/packages/enzyme-test-suite/test/shared/methods/findWhere.jsx
+++ b/packages/enzyme-test-suite/test/shared/methods/findWhere.jsx
@@ -96,12 +96,12 @@ export default function describeFindWhere({
const selector = 'blah';
const wrapper = Wrap();
- const foundSpan = wrapper.findWhere(n => (
+ const foundSpan = wrapper.findWhere((n) => (
n.type() === 'span' && n.props()['data-foo'] === selector
));
expect(foundSpan.type()).to.equal('span');
- const foundNotSpan = wrapper.findWhere(n => (
+ const foundNotSpan = wrapper.findWhere((n) => (
n.type() !== 'span' && n.props()['data-foo'] === selector
));
expect(foundNotSpan.type()).to.equal('i');
@@ -129,14 +129,14 @@ export default function describeFindWhere({
const selector = 'blah';
const wrapper = Wrap();
- const foundSpans = wrapper.findWhere(n => (
+ const foundSpans = wrapper.findWhere((n) => (
n.type() === 'span' && n.props()['data-foo'] === selector
));
expect(foundSpans).to.have.lengthOf(2);
expect(foundSpans.get(0).type).to.equal('span');
expect(foundSpans.get(1).type).to.equal('span');
- const foundNotSpans = wrapper.findWhere(n => (
+ const foundNotSpans = wrapper.findWhere((n) => (
n.type() !== 'span' && n.props()['data-foo'] === selector
));
expect(foundNotSpans).to.have.lengthOf(2);
@@ -160,12 +160,12 @@ export default function describeFindWhere({
const selector = 'blah';
const wrapper = Wrap();
- const foundSpan = wrapper.findWhere(n => (
+ const foundSpan = wrapper.findWhere((n) => (
n.type() === 'span' && n.props()['data-foo'] === selector
));
expect(foundSpan.type()).to.equal('span');
- const foundNotSpan = wrapper.findWhere(n => (
+ const foundNotSpan = wrapper.findWhere((n) => (
n.type() !== 'span' && n.props()['data-foo'] === selector
));
expect(foundNotSpan).to.have.lengthOf(0);
@@ -193,7 +193,7 @@ export default function describeFindWhere({
const selector = 'blah';
const wrapper = Wrap();
- const foundSpan = wrapper.findWhere(n => (
+ const foundSpan = wrapper.findWhere((n) => (
n.type() === 'span'
&& n.props()['data-foo'] === selector
));
@@ -248,12 +248,12 @@ export default function describeFindWhere({
const selector = 'blah';
const wrapper = Wrap();
- const foundSpan = wrapper.findWhere(n => (
+ const foundSpan = wrapper.findWhere((n) => (
n.type() === 'span' && n.props()['data-foo'] === selector
));
expect(foundSpan.type()).to.equal('span');
- const foundNotSpan = wrapper.findWhere(n => (
+ const foundNotSpan = wrapper.findWhere((n) => (
n.type() !== 'span' && n.props()['data-foo'] === selector
));
expect(foundNotSpan.type()).to.equal('i');
@@ -271,12 +271,12 @@ export default function describeFindWhere({
const selector = 'blah';
const wrapper = Wrap();
- const foundSpan = wrapper.findWhere(n => (
+ const foundSpan = wrapper.findWhere((n) => (
n.type() === 'span' && n.props()['data-foo'] === selector
));
expect(foundSpan.type()).to.equal('span');
- const foundNotSpan = wrapper.findWhere(n => (
+ const foundNotSpan = wrapper.findWhere((n) => (
n.type() !== 'span' && n.props()['data-foo'] === selector
));
expect(foundNotSpan).to.have.lengthOf(0);
@@ -349,7 +349,7 @@ export default function describeFindWhere({
const passedNodes = stub.getCalls().map(({ args: [firstArg] }) => firstArg);
- const textContents = passedNodes.map(n => [n.debug(), n.text()]);
+ const textContents = passedNodes.map((n) => [n.debug(), n.text()]);
const expected = [
[wrapper.debug(), 'foo bar'], // root
['', ''], // first div
@@ -372,8 +372,8 @@ export default function describeFindWhere({
wrapper.findWhere(stub);
const passedNodes = stub.getCalls().map(({ args: [firstArg] }) => firstArg);
- const getElement = n => (isShallow ? n.getElement() : n.getDOMNode());
- const hasElements = passedNodes.map(n => [n.debug(), getElement(n) && true]);
+ const getElement = (n) => (isShallow ? n.getElement() : n.getDOMNode());
+ const hasElements = passedNodes.map((n) => [n.debug(), getElement(n) && true]);
const expected = [
[wrapper.debug(), true], // root
['', true], // first div
@@ -414,7 +414,7 @@ export default function describeFindWhere({
const wrapper = Wrap();
- expect(wrapper.findWhere(node => node.type() === Portal)).to.have.lengthOf(1);
+ expect(wrapper.findWhere((node) => node.type() === Portal)).to.have.lengthOf(1);
});
});
}
diff --git a/packages/enzyme-test-suite/test/shared/methods/flatMap.jsx b/packages/enzyme-test-suite/test/shared/methods/flatMap.jsx
index 0398cf5ba..855d8e0be 100644
--- a/packages/enzyme-test-suite/test/shared/methods/flatMap.jsx
+++ b/packages/enzyme-test-suite/test/shared/methods/flatMap.jsx
@@ -23,7 +23,7 @@ export default function describeFlatMap({
));
- const nodes = wrapper.find('.foo').flatMap(w => w.children().getElements());
+ const nodes = wrapper.find('.foo').flatMap((w) => w.children().getElements());
expect(nodes).to.have.lengthOf(6);
expect(nodes.at(0).hasClass('bar')).to.equal(true);
diff --git a/packages/enzyme-test-suite/test/shared/methods/getWrappingComponent.jsx b/packages/enzyme-test-suite/test/shared/methods/getWrappingComponent.jsx
index d19b08e59..ab390e266 100644
--- a/packages/enzyme-test-suite/test/shared/methods/getWrappingComponent.jsx
+++ b/packages/enzyme-test-suite/test/shared/methods/getWrappingComponent.jsx
@@ -195,7 +195,7 @@ export default function describeGetWrappingComponent({
}
const wrapper = Wrap((