Skip to content

Commit c1098fc

Browse files
author
Thomas Guthruf
committed
added tests
1 parent 13c0b1b commit c1098fc

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/tests/html.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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 () {

0 commit comments

Comments
 (0)