Skip to content

Commit

Permalink
[Fix] mount: setContext: use proper wrapper name in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 25, 2019
1 parent 0c3277c commit df7ad40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Expand Up @@ -2630,7 +2630,7 @@ describeWithDOM('mount', () => {
const wrapper = mount(<SimpleComponent />);
expect(() => wrapper.setContext({ name: 'bar' })).to.throw(
Error,
'ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
'ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
);
});

Expand Down Expand Up @@ -2659,7 +2659,7 @@ describeWithDOM('mount', () => {
const wrapper = mount(<SimpleComponent />);
expect(() => wrapper.setContext({ name: 'bar' })).to.throw(
Error,
'ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
'ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
);
});
});
Expand Down Expand Up @@ -8859,7 +8859,7 @@ describeWithDOM('mount', () => {

onChange() {
// enzyme can't handle the update because `this` is a ReactComponent instance,
// not a ShallowWrapper instance.
// not a Wrapper instance.
this.setState({ foo: 'onChange update' });
}

Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme/src/ReactWrapper.js
Expand Up @@ -353,7 +353,7 @@ class ReactWrapper {
throw new Error('ReactWrapper::setContext() can only be called on the root');
}
if (!this[OPTIONS].context) {
throw new Error('ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option');
throw new Error('ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option');
}
this[RENDERER].render(this[UNRENDERED], context, () => this.update());
return this;
Expand Down

0 comments on commit df7ad40

Please sign in to comment.