Skip to content

Commit

Permalink
[bugfix] nodeHasId has issue with 0.14 in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandrichardson committed Dec 10, 2015
1 parent 9d5d3de commit 3f2e672
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/ShallowTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ export function parentsOfNode(node, root) {
}

export function nodeHasId(node, id) {
const maybeId = node && node._store && node._store.props && node._store.props.id;
return maybeId === id;
return propsOfNode(node).id === id;
}

export function nodeHasType(node, type) {
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/ShallowWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ describe('shallow', () => {

describe('.find(selector)', () => {

it('should be able to match the root DOM element', () => {
const wrapper = shallow(<div id="ttt" className="ttt">hello</div>);
expect(wrapper.find('#ttt')).to.have.length(1);
expect(wrapper.find('.ttt')).to.have.length(1);
});

it('should find an element based on a class name', () => {
const wrapper = shallow(
<div>
Expand Down

0 comments on commit 3f2e672

Please sign in to comment.