diff --git a/test/ShallowWrapper-spec.js b/test/ShallowWrapper-spec.js index 6820592ad..f781c0787 100644 --- a/test/ShallowWrapper-spec.js +++ b/test/ShallowWrapper-spec.js @@ -2288,6 +2288,33 @@ describe('shallow', () => { )).to.equal(true); expect(spy.callCount).to.equal(0); }); + it('should not match on a root node that doesn\'t looks like the rendered one', () => { + const spy = sinon.spy(); + const spy2 = sinon.spy(); + const wrapper = shallow( +
+
Hello World
+
+ ).first(); + expect(wrapper.matchesElement(
Bonjour le monde
)).to.equal(false); + expect(wrapper.matchesElement( +
+
Hello World
+
+ )).to.equal(false); + expect(wrapper.matchesElement( +
+
Hello World
+
+ )).to.equal(false); + expect(wrapper.matchesElement( +
+
Hello World
+
+ )).to.equal(false); + expect(spy.callCount).to.equal(0); + expect(spy2.callCount).to.equal(0); + }); }); describe('.containsMatchingElement(node)', () => { @@ -2369,6 +2396,22 @@ describe('shallow', () => { expect(spy1.callCount).to.equal(0); expect(spy2.callCount).to.equal(0); }); + it('should not match on a single node that doesn\'t looks like a rendered one', () => { + const spy1 = sinon.spy(); + const spy2 = sinon.spy(); + const wrapper = shallow( +
+
Hello World
+
Goodbye World
+
+ ); + expect(wrapper.containsMatchingElement( +
Bonjour le monde
+ )).to.equal(false); + expect(wrapper.containsMatchingElement( +
Au revoir le monde
+ )).to.equal(false); + }); }); describe('.containsAllMatchingElements(nodes)', () => { it('should match on an array of nodes that all looks like one of rendered nodes', () => { @@ -2415,6 +2458,23 @@ describe('shallow', () => { expect(spy1.callCount).to.equal(0); expect(spy2.callCount).to.equal(0); }); + it('should not match on nodes that doesn\'t all looks like one of rendered nodes', () => { + const spy1 = sinon.spy(); + const spy2 = sinon.spy(); + const wrapper = shallow( +
+
Hello World
+
Goodbye World
+
+ ); + expect(wrapper.containsAllMatchingElements([ +
Hello World
, +
Bonjour le monde
, +
Goodbye World
, + ])).to.equal(false); + expect(spy1.callCount).to.equal(0); + expect(spy2.callCount).to.equal(0); + }); }); describe('.containsAnyMatchingElements(nodes)', () => { @@ -2462,5 +2522,21 @@ describe('shallow', () => { expect(spy1.callCount).to.equal(0); expect(spy2.callCount).to.equal(0); }); + it('should not match on an array with no nodes that looks like a rendered nodes', () => { + const spy1 = sinon.spy(); + const spy2 = sinon.spy(); + const wrapper = shallow( +
+
Hello World
+
Goodbye World
+
+ ); + expect(wrapper.containsAnyMatchingElements([ +
Bonjour le monde
, +
Au revoir le monde
, + ])).to.equal(false); + expect(spy1.callCount).to.equal(0); + expect(spy2.callCount).to.equal(0); + }); }); });