Skip to content

Commit

Permalink
Expand :has() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Qard authored and michaelficarra committed Apr 13, 2017
1 parent 3345254 commit 9e28797
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/queryHas.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ define([
"conditional": function () {
var matches = esquery(conditional, 'ExpressionStatement:has([name="foo"][type="Identifier"])');
assert.isEqual(1, matches.length);
},

"one of": function () {
var matches = esquery(conditional, 'IfStatement:has(LogicalExpression [name="foo"], LogicalExpression [name="x"])');
assert.isEqual(1, matches.length);
},

"chaining": function () {
var matches = esquery(conditional, 'BinaryExpression:has(Identifier[name="x"]):has(Literal[value="test"])');
assert.isEqual(1, matches.length);
},

"nesting": function () {
var matches = esquery(conditional, 'Program:has(IfStatement:has(Literal[value=true], Literal[value=false]))');
assert.isEqual(1, matches.length);
},

"non-matching": function () {
var matches = esquery(conditional, ':has([value="impossible"])');
assert.isEqual(0, matches.length);
}

});
Expand Down

0 comments on commit 9e28797

Please sign in to comment.