Skip to content

Commit

Permalink
Found and fix a mount issue with find when using a named component e.…
Browse files Browse the repository at this point in the history
…g. find('Foo')
  • Loading branch information
CurtisHumphrey committed Mar 4, 2016
1 parent f1bb212 commit d8c021f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/MountedTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {
isElement,
findDOMNode,
} from './react-compat';
import {
nodeHasType,
} from './ShallowTraversal';
import { REACT013, REACT014 } from './version';

export function internalInstance(inst) {
Expand Down Expand Up @@ -62,8 +65,7 @@ export function instHasId(inst, id) {
export function instHasType(inst, type) {
switch (typeof type) {
case 'string':
return isDOMComponent(inst) &&
inst.tagName.toUpperCase() === type.toUpperCase();
return nodeHasType(getNode(inst), type);
case 'function':
return isCompositeComponentWithType(inst, type);
default:
Expand Down
12 changes: 12 additions & 0 deletions test/ReactWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ describeWithDOM('mount', () => {
expect(wrapper.find(Foo).type()).to.equal(Foo);
});

it('should find a component based on a component displayName', () => {
class Foo extends React.Component {
render() { return <div />; }
}
const wrapper = mount(
<div>
<Foo className="foo" />
</div>
);
expect(wrapper.find('Foo').type()).to.equal(Foo);
});

it('should find component based on a react prop', () => {
const wrapper = mount(
<div>
Expand Down

0 comments on commit d8c021f

Please sign in to comment.