forked from component/matches-selector
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
24 lines (19 loc) · 740 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var matches = require('./');
document.body.innerHTML = '<ul><li><em>foo</em></li></ul>';
var ul = document.body.children[0];
var li = ul.children[0];
var em = li.children[0];
describe('matchesSelector(el, selector)', function(){
it('should work', function(){
expect(matches(em, 'ul li em')).to.be.true;
expect(matches(em, 'ul em')).to.be.true;
expect(matches(em, 'ul > li > em')).to.be.true;
expect(matches(em, 'ul ul em')).to.be.false;
expect(matches(li, 'ul li')).to.be.true;
expect(matches(li, 'ul > li')).to.be.true;
expect(matches(li, 'li')).to.be.true;
expect(matches(li, 'div > li')).to.be.false;
expect(matches(ul, 'ul')).to.be.true;
expect(matches(ul, 'div ul')).to.be.false;
})
})