@@ -834,6 +834,41 @@ describe('unexpected-dom', function () {
834
834
} ) ;
835
835
} ) ;
836
836
837
+ describe ( 'to contain no elements matching' , function ( ) {
838
+ it ( 'should pass when not matching anything' , function ( ) {
839
+ var document = jsdom . jsdom ( '<!DOCTYPE html><html><body></body></html>' ) ;
840
+
841
+ expect ( document , 'to contain no elements matching' , '.foo' ) ;
842
+ } ) ;
843
+
844
+ it ( 'should fail when matching a single node' , function ( ) {
845
+ var document = jsdom . jsdom ( '<!DOCTYPE html><html><body><div class="foo"></div></body></html>' ) ;
846
+
847
+ expect ( function ( ) {
848
+ expect ( document , 'to contain no elements matching' , '.foo' ) ;
849
+ } , 'to throw' , 'expected <!DOCTYPE html><html><head></head><body>...</body></html> to contain no elements matching \'.foo\'\n' +
850
+ '\n' +
851
+ '[\n' +
852
+ ' <div class="foo"></div> // should be removed\n' +
853
+ ']'
854
+ ) ;
855
+ } ) ;
856
+
857
+ it ( 'should fail when matching a NodeList' , function ( ) {
858
+ var document = jsdom . jsdom ( '<!DOCTYPE html><html><body><div class="foo"></div><div class="foo"></div></body></html>' ) ;
859
+
860
+ expect ( function ( ) {
861
+ expect ( document , 'to contain no elements matching' , '.foo' ) ;
862
+ } , 'to throw' , 'expected <!DOCTYPE html><html><head></head><body>......</body></html> to contain no elements matching \'.foo\'\n' +
863
+ '\n' +
864
+ '[\n' +
865
+ ' <div class="foo"></div>, // should be removed\n' +
866
+ ' <div class="foo"></div> // should be removed\n' +
867
+ ']'
868
+ ) ;
869
+ } ) ;
870
+ } ) ;
871
+
837
872
describe ( 'diffing' , function ( ) {
838
873
function parseHtmlElement ( str ) {
839
874
return jsdom . jsdom ( '<!DOCTYPE html><html><body>' + str + '</body></html>' ) . body . firstChild ;
0 commit comments