Skip to content

Commit

Permalink
[enzyme-adapter-react-14] [fix] mount: make sure it works with nati…
Browse files Browse the repository at this point in the history
…ve arrow functions

Fixes #1667.
  • Loading branch information
ljharb committed Jun 29, 2018
1 parent 48e0d20 commit 2ca9639
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
"plugins": [
["transform-replace-object-assign", "object.assign"],
],
ignore: [
"packages/enzyme-test-suite/test/_helpers/untranspiled*",
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {

function typeToNodeType(type) {
if (typeof type === 'function') {
if (typeof type.prototype.render === 'function') {
if (type.prototype && typeof type.prototype.render === 'function') {
return 'class';
}
return 'function';
Expand Down
10 changes: 10 additions & 0 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
generateEmptyRenderData,
} from './_helpers';
import { REACT013, REACT014, REACT16, REACT163, is } from './_helpers/version';
import realArrowFunction from './_helpers/realArrowFunction';

const getElementPropSelector = prop => x => x.props[prop];
const getWrapperPropSelector = prop => x => x.prop(prop);
Expand Down Expand Up @@ -1103,6 +1104,15 @@ describeWithDOM('mount', () => {
</SFC>`
));
});

it('works with a nested SFC', () => {
const Bar = realArrowFunction(<div>Hello</div>);
class Foo extends React.Component {
render() { return <Bar />; }
}
const wrapper = mount(<Foo />);
expect(wrapper.text()).to.equal('Hello');
});
});

it('does not pass in null or false nodes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// this file is ignored in babelrc, specifically so that tests will be able to run
// on a real arrow function that lacks a .prototype
module.exports = x => () => x;

0 comments on commit 2ca9639

Please sign in to comment.