1 | 'use strict';
|
2 |
|
3 | var test = require('tape');
|
4 | var domify = require('domify');
|
5 | var matches = require('../');
|
6 |
|
7 | var ul = domify('<ul><li><em>foo</em></li></ul>');
|
8 | var li = ul.children[0];
|
9 | var em = li.children[0];
|
10 |
|
11 | test('matchesSelector(el, selector)', function (t) {
|
12 | t.plan(12);
|
13 |
|
14 | t.assert(true === matches(em, 'ul li em'), 'em = "ul li em"');
|
15 | t.assert(true === matches(em, 'ul em'), 'em = "ul em"');
|
16 | t.assert(true === matches(em, 'ul > li > em'), 'em = "ul > li > em"');
|
17 | t.assert(false === matches(em, 'ul ul em'), 'em != "ul ul em"');
|
18 |
|
19 | t.assert(true === matches(li, 'ul li'), 'li = "ul li"');
|
20 | t.assert(true === matches(li, 'ul > li'), 'li = "ul > li"');
|
21 | t.assert(true === matches(li, 'li'), 'li = "li"');
|
22 | t.assert(false === matches(li, 'div > li'), 'li != "div > li"');
|
23 |
|
24 | t.assert(true == matches(ul, 'ul', 'ul = "ul"'), 'ul = "ul"');
|
25 | t.assert(false == matches(ul, 'body > ul'), 'ul != "body > ul"');
|
26 |
|
27 | t.assert(false === matches(em.firstChild, 'ul'), 'match on textNode is false');
|
28 | t.assert(false === matches(null, 'ul'), 'match on null is false');
|
29 | })
|