Skip to content

Commit

Permalink
Add shallow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Mar 16, 2018
1 parent 81167fb commit 419780b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.6.1"
}
}
}
20 changes: 18 additions & 2 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 (
<Consumer>{value => <span>{value}</span>}</Consumer>
);
}
}

const wrapper = mount(<Provider value="foo"><div><Foo /></div></Provider>);

expect(wrapper.find('span').text()).to.equal('foo');
});

describeIf(!REACT013, 'stateless function components', () => {
it('can pass in context', () => {
const SimpleComponent = (props, context) => (
Expand Down

0 comments on commit 419780b

Please sign in to comment.