Skip to content

Commit

Permalink
fix numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
smacker committed Jan 29, 2016
1 parent 07dcd56 commit baddf12
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/ShallowWrapper.js
Expand Up @@ -202,13 +202,7 @@ export default class ShallowWrapper {
* @returns {Boolean}
*/
contains(node) {
let nodeToCompare = node;

if (typeof nodeToCompare === 'number') {
nodeToCompare = '' + nodeToCompare;
}

return findWhereUnwrapped(this, other => nodeEqual(nodeToCompare, other)).length > 0;
return findWhereUnwrapped(this, other => nodeEqual(node, other)).length > 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.js
Expand Up @@ -82,7 +82,7 @@ export function nodeEqual(a, b) {
}
}

if (typeof a !== 'string') {
if (typeof a !== 'string' && typeof a !== 'number') {
return leftKeys.length === Object.keys(right).length;
}

Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/ShallowWrapper-spec.js
Expand Up @@ -91,10 +91,11 @@ describe('shallow', () => {
});

it('should work with numbers', () => {
const wrapper = shallow(<div>1</div>);
const wrapper = shallow(<div>{1}</div>);

expect(wrapper.contains(1)).to.equal(true);
expect(wrapper.contains(2)).to.equal(false);
expect(wrapper.contains('1')).to.equal(false);
});

});
Expand Down

0 comments on commit baddf12

Please sign in to comment.