diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
index eb5eda05c..c14f852e6 100644
--- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
@@ -673,17 +673,18 @@ describe('shallow', () => {
class OuterComponent extends React.Component {
render() {
+ const { value } = this.props;
return (
-
+
);
}
}
class WrappingComponent extends React.Component {
render() {
- const { children } = this.props;
+ const { children, value } = this.props;
return (
- { children }
+ { children }
);
}
}
@@ -696,16 +697,45 @@ describe('shallow', () => {
InnerComponent.contextType = Provider;
- it('works on a Provider', () => {
- const wrapper = shallow();
- const provides = wrapper.find(Provider).shallow();
- const provider = provides.find(InnerComponent).shallow();
- expect(provider.text()).to.equal('foo');
+ describe('rendering the Provider directly', () => {
+ it('renders initial context value', () => {
+ const wrapper = shallow();
+ const provides = wrapper.find(Provider).shallow();
+ const provider = provides.find(InnerComponent).shallow();
+
+ expect(provider.text()).to.equal('foo');
+ });
+
+ it('renders updated context value', () => {
+ const wrapper = shallow();
+ wrapper.setProps({ value: 'bar' });
+ const provides = wrapper.find(Provider).shallow();
+ const provider = provides.find(InnerComponent).shallow();
+
+ expect(provider.text()).to.equal('bar');
+ });
});
- it('works with wrappingComponent', () => {
- const wrapper = shallow(, { wrappingComponent: WrappingComponent });
- expect(wrapper.text()).to.equal('foo');
+ describe('rendereing the Provider through wrappingComponent', () => {
+ it('renders initial context value', () => {
+ const wrapper = shallow(, {
+ wrappingComponent: WrappingComponent,
+ wrappingComponentProps: { value: 'foo' },
+ });
+
+ expect(wrapper.text()).to.equal('foo');
+ });
+
+ it('renders updated context value', () => {
+ const wrapper = shallow(, {
+ wrappingComponent: WrappingComponent,
+ wrappingComponentProps: { value: 'foo' },
+ });
+ const wrappingComponent = wrapper.getWrappingComponent();
+ wrappingComponent.setProps({ value: 'bar' });
+ wrapper.update();
+ expect(wrapper.text()).to.equal('bar');
+ });
});
});
});