From df7ad40a088b0f1cee083e007b07793741d6ce59 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 Mar 2019 08:46:38 -0700 Subject: [PATCH] [Fix] `mount`: `setContext`: use proper wrapper name in error message --- packages/enzyme-test-suite/test/ReactWrapper-spec.jsx | 6 +++--- packages/enzyme/src/ReactWrapper.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx index 23d55e3a6..020f1cced 100644 --- a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx @@ -2630,7 +2630,7 @@ describeWithDOM('mount', () => { const wrapper = mount(); 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 ); }); @@ -2659,7 +2659,7 @@ describeWithDOM('mount', () => { const wrapper = mount(); 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 ); }); }); @@ -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' }); } diff --git a/packages/enzyme/src/ReactWrapper.js b/packages/enzyme/src/ReactWrapper.js index 4a2d60ed6..87c048713 100644 --- a/packages/enzyme/src/ReactWrapper.js +++ b/packages/enzyme/src/ReactWrapper.js @@ -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;