File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -789,6 +789,23 @@ describe('HTML Parser', function () {
789789 root . children . length . should . eql ( 3 ) ;
790790 } ) ;
791791 } ) ;
792+
793+ describe ( '#matches' , ( ) => {
794+ it ( '`HTMLElement` should match CSS selector' , ( ) => {
795+ const html = parseHTML ( `<div class="example-class" data-test="example-data" id="example-id"></div>` ) ;
796+ html . firstChild . matches ( '.example-class' ) . should . be . true ( ) ;
797+ html . firstChild . matches ( '#example-id' ) . should . be . true ( ) ;
798+ html . firstChild . matches ( 'div' ) . should . be . true ( ) ;
799+ html . firstChild . matches ( '[data-test="example-data"]' ) . should . be . true ( ) ;
800+ } ) ;
801+ it ( '`HTMLElement` should not match CSS selector ' , ( ) => {
802+ const html = parseHTML ( `<div></div>` ) ;
803+ html . firstChild . matches ( '.no-match' ) . should . be . false ( ) ;
804+ html . firstChild . matches ( '#no-match' ) . should . be . false ( ) ;
805+ html . firstChild . matches ( 'span' ) . should . be . false ( ) ;
806+ html . firstChild . matches ( '[data-test="no-match"]' ) . should . be . false ( ) ;
807+ } ) ;
808+ } ) ;
792809 } ) ;
793810
794811 describe ( 'stringify' , function ( ) {
You can’t perform that action at this time.
0 commit comments