Skip to content

Commit d06d88b

Browse files
committed
Expand :has() tests
1 parent 8126a30 commit d06d88b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/queryHas.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@ define([
1111
"conditional": function () {
1212
var matches = esquery(conditional, 'ExpressionStatement:has([name="foo"][type="Identifier"])');
1313
assert.isEqual(1, matches.length);
14+
},
15+
16+
"one of": function () {
17+
var matches = esquery(conditional, 'IfStatement:has(LogicalExpression [name="foo"], LogicalExpression [name="x"])');
18+
assert.isEqual(1, matches.length);
19+
},
20+
21+
"chaining": function () {
22+
var matches = esquery(conditional, 'BinaryExpression:has(Identifier[name="x"]):has(Literal[value="test"])');
23+
assert.isEqual(1, matches.length);
24+
},
25+
26+
"nesting": function () {
27+
var matches = esquery(conditional, 'Program:has(IfStatement:has(Literal[value=true], Literal[value=false]))');
28+
assert.isEqual(1, matches.length);
29+
},
30+
31+
"non-matching": function () {
32+
var matches = esquery(conditional, ':has([value="impossible"])');
33+
assert.isEqual(0, matches.length);
1434
}
1535

1636
});

0 commit comments

Comments
 (0)