Skip to content

Commit

Permalink
[Tests] shallow: .dive(): update tests to match intended semantics
Browse files Browse the repository at this point in the history
Merge pull request #2132 from tilgovi/context-dive-update-failing-test-case
  • Loading branch information
ljharb authored May 22, 2019
2 parents d94d25d + 48479f3 commit 78034b1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,25 @@ describe('shallow', () => {
expect(consumer.context()).to.eql(expectedContext);
});

it('propagates updates to rendered children', () => {
const wrapper = shallow(<TestComponent />, { context: { baz: 'enzyme' } });

const fooProvider = wrapper.find(FooProvider).dive();
const barProvider = fooProvider.find(BarProvider).dive();
const consumer = barProvider.find(FooBarBazConsumer).dive();

expect(consumer.context()).to.eql({ foo: 'i', bar: 'love', baz: 'enzyme' });

fooProvider.setProps({ value: 'we' });

const nextBarProvider = fooProvider.find(BarProvider).dive();
nextBarProvider.setState({ value: 'maintain' });
const nextConsumer = nextBarProvider.find(FooBarBazConsumer).dive();

const expectedContext = { foo: 'we', bar: 'maintain', baz: 'enzyme' };
expect(nextConsumer.context()).to.eql(expectedContext);
});

it('does nothing if disableLifecycleMethods is true', () => {
const wrapper = shallow(<TestComponent />, {
context: { baz: 'enzyme' },
Expand Down

0 comments on commit 78034b1

Please sign in to comment.