From 766f9ec4f96620995d4ec744e7b65e64e91978ac Mon Sep 17 00:00:00 2001 From: Luka Jeran Date: Sat, 3 Aug 2024 19:34:50 +0000 Subject: [PATCH] Test selectors after exactNode --- tests/queryHas.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/queryHas.js b/tests/queryHas.js index 5484219..3d36519 100644 --- a/tests/queryHas.js +++ b/tests/queryHas.js @@ -35,4 +35,29 @@ describe('Parent selector query', function () { const shallowChildMatches = esquery(conditional, 'IfStatement:has(> LogicalExpression.test, > Identifier[name="x"])'); assert.equal(1, shallowChildMatches.length); }); + + it('has(>BlockStatement)', function () { + const matches = esquery(conditional, 'IfStatement:has(>BlockStatement)'); + assert.equal(3, matches.length); + }); + it('has(BlockStatement>ExpressionStatement)', function () { + const matches = esquery(conditional, 'IfStatement:has(BlockStatement>ExpressionStatement)'); + assert.equal(3, matches.length); + }); + it('fails has(>BlockStatement>ExpressionStatement)', function () { + const matches = esquery(conditional, 'IfStatement:has(>BlockStatement>ExpressionStatement)'); + assert.equal(3, matches.length); + }); + it('workaround has(>BlockStatement:has(>ExpressionStatement))', function () { + const matches = esquery(conditional, 'IfStatement:has(>BlockStatement:has(>ExpressionStatement))'); + assert.equal(3, matches.length); + }); + it('fails has(>BlockStatement ExpressionStatement)', function () { + const matches = esquery(conditional, 'IfStatement:has(>BlockStatement ExpressionStatement)'); + assert.equal(3, matches.length); + }); + it('workaround has(>BlockStatement:has(ExpressionStatement))', function () { + const matches = esquery(conditional, 'IfStatement:has(>BlockStatement:has(ExpressionStatement))'); + assert.equal(3, matches.length); + }); });