Skip to content

Commit

Permalink
[Fix] shallow: .contains(): clean up error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 19, 2019
1 parent 4c1656d commit 7ff8ea2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,11 @@ describe('shallow', () => {

expect(() => wrapper.contains({})).to.throw(
Error,
'ShallowWrapper::contains() can only be called with ReactElement (or array of them), string or number as argument.', // eslint-disable-line max-len
'ShallowWrapper::contains() can only be called with a ReactElement (or an array of them), a string, or a number as an argument.',
);
expect(() => wrapper.contains(() => ({}))).to.throw(
Error,
'ShallowWrapper::contains() can only be called with ReactElement (or array of them), string or number as argument.', // eslint-disable-line max-len
'ShallowWrapper::contains() can only be called with a ReactElement (or an array of them), a string, or a number as an argument.',
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ class ShallowWrapper {
contains(nodeOrNodes) {
const adapter = getAdapter(this[OPTIONS]);
if (!isReactElementAlike(nodeOrNodes, adapter)) {
throw new Error('ShallowWrapper::contains() can only be called with ReactElement (or array of them), string or number as argument.');
throw new Error('ShallowWrapper::contains() can only be called with a ReactElement (or an array of them), a string, or a number as an argument.');
}
const predicate = Array.isArray(nodeOrNodes)
? other => containsChildrenSubArray(
Expand Down

0 comments on commit 7ff8ea2

Please sign in to comment.