Skip to content

Commit

Permalink
[Tests] add matchesElement tests
Browse files Browse the repository at this point in the history
Closes #642.
  • Loading branch information
ljharb committed Aug 31, 2018
1 parent 4404e3c commit d38a9d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5796,7 +5796,7 @@ describeWithDOM('mount', () => {
expect(spy).to.have.property('callCount', 0);
});

it('does not match on a root node that doesn\'t looks like the rendered one', () => {
it('does not match on a root node that doesnt looks like the rendered one', () => {
const spy = sinon.spy();
const spy2 = sinon.spy();
const wrapper = mount((
Expand All @@ -5823,6 +5823,16 @@ describeWithDOM('mount', () => {
expect(spy).to.have.property('callCount', 0);
expect(spy2).to.have.property('callCount', 0);
});

it('matches a simple node', () => {
class Test extends React.Component {
render() {
return <h1>test</h1>;
}
}
const wrapper = mount(<Test />);
expect(wrapper.children().matchesElement(<h1>test</h1>)).to.equal(true);
});
});

describe('.containsMatchingElement(node)', () => {
Expand Down
12 changes: 11 additions & 1 deletion packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5952,7 +5952,7 @@ describe('shallow', () => {
expect(spy).to.have.property('callCount', 0);
});

it('does not match on a root node that doesn\'t looks like the rendered one', () => {
it('does not match on a root node that doesnt looks like the rendered one', () => {
const spy = sinon.spy();
const spy2 = sinon.spy();
const wrapper = shallow((
Expand All @@ -5979,6 +5979,16 @@ describe('shallow', () => {
expect(spy).to.have.property('callCount', 0);
expect(spy2).to.have.property('callCount', 0);
});

it('matches a simple node', () => {
class Test extends React.Component {
render() {
return <h1>test</h1>;
}
}
const wrapper = shallow(<Test />);
expect(wrapper.matchesElement(<h1>test</h1>)).to.equal(true);
});
});

describe('.containsMatchingElement(node)', () => {
Expand Down

0 comments on commit d38a9d8

Please sign in to comment.