Skip to content

Commit

Permalink
Add tests for not finding ref or key
Browse files Browse the repository at this point in the history
  • Loading branch information
blainekasten committed Dec 18, 2015
1 parent 2391ca7 commit 80b14d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/__tests__/ReactWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ describeWithDOM('mount', () => {
expect(wrapper.find('a[value=true]')).to.have.length(0);
});

it('should not find key or ref via property selector', () => {
class Foo extends React.Component {
render() {
const arrayOfComponents = [<div key="1" />, <div key="2" />];

return (
<div>
<div ref="foo" />
{arrayOfComponents}
</div>
);
}
}


const wrapper = mount(<Foo />);

expect(wrapper.find('div[ref="foo"]')).to.have.length(0);
expect(wrapper.find('div[key="1"]')).to.have.length(0);
});


it('should find multiple elements based on a class name', () => {
const wrapper = mount(
Expand Down
13 changes: 13 additions & 0 deletions src/__tests__/ShallowWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ describe('shallow', () => {
expect(wrapper.find('a[value=true]')).to.have.length(0);
});

it('should not find key or ref via property selector', () => {
const arrayOfComponents = [<div key="1" />, <div key="2" />];
const wrapper = shallow(
<div>
<div ref="foo" />
{arrayOfComponents}
</div>
);

expect(wrapper.find('div[ref="foo"]')).to.have.length(0);
expect(wrapper.find('div[key="1"]')).to.have.length(0);
});

it('should find multiple elements based on a constructor', () => {
const wrapper = shallow(
<div>
Expand Down

0 comments on commit 80b14d3

Please sign in to comment.