From 419780b1bb3a2f0580472ac702e996da254fb226 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Fri, 16 Mar 2018 11:17:30 -0400 Subject: [PATCH] Add shallow tests --- packages/enzyme-test-suite/package.json | 2 +- .../test/ShallowWrapper-spec.jsx | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/enzyme-test-suite/package.json b/packages/enzyme-test-suite/package.json index eefd20e92..abbce8eb3 100644 --- a/packages/enzyme-test-suite/package.json +++ b/packages/enzyme-test-suite/package.json @@ -49,4 +49,4 @@ "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.6.1" } -} +} \ No newline at end of file diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx index 22e14d897..d442ee4ad 100644 --- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx @@ -6,9 +6,9 @@ import { shallow, render, ShallowWrapper, mount } from 'enzyme'; import { ITERATOR_SYMBOL, withSetStateAllowed, sym } from 'enzyme/build/Utils'; import './_helpers/setupAdapters'; -import { createClass } from './_helpers/react-compat'; +import { createClass, createContext } from './_helpers/react-compat'; import { describeIf, itIf, itWithData, generateEmptyRenderData } from './_helpers'; -import { REACT013, REACT014, REACT15, REACT150_4, REACT16, is } from './_helpers/version'; +import { REACT013, REACT014, REACT15, REACT150_4, REACT16, REACT163, is } from './_helpers/version'; // The shallow renderer in react 16 does not yet support batched updates. When it does, // we should be able to go un-skip all of the tests that are skipped with this flag. @@ -96,6 +96,22 @@ describe('shallow', () => { expect(wrapper.context('name')).to.equal(context.name); }); + itIf(REACT163, 'should find elements through Context elements', () => { + const { Provider, Consumer } = createContext(''); + + class Foo extends React.Component { + render() { + return ( + {value => {value}} + ); + } + } + + const wrapper = mount(
); + + expect(wrapper.find('span').text()).to.equal('foo'); + }); + describeIf(!REACT013, 'stateless function components', () => { it('can pass in context', () => { const SimpleComponent = (props, context) => (