From 92d6b8b92c8ae5907b5070bcfcc12b9e7c67bdac Mon Sep 17 00:00:00 2001 From: Slava Leleka Date: Wed, 5 Oct 2022 14:07:58 +0300 Subject: [PATCH] AG-16783 add few not(has(not)) tests Squashed commit of the following: commit c38f3a00df786c19e03f30ebf734539bea60349f Author: Slava Leleka Date: Tue Oct 4 17:05:54 2022 +0300 add few not(has(not)) tests --- test/selector/parser.test.ts | 61 +++++++++++++++++++++++++++++++ test/selector/query-jsdom.test.ts | 2 + 2 files changed, 63 insertions(+) diff --git a/test/selector/parser.test.ts b/test/selector/parser.test.ts index cd9265b5..1557d0f0 100644 --- a/test/selector/parser.test.ts +++ b/test/selector/parser.test.ts @@ -1187,6 +1187,67 @@ describe('combined extended selectors', () => { expect(parse(selector)).toEqual(expected); }); + it('not(has(not))', () => { + const actual = 'div:not(:has(:not(img)))'; + const expected = { + type: NodeType.SelectorList, + children: [ + { + type: NodeType.Selector, + children: [ + getRegularSelector('div'), + { + type: NodeType.ExtendedSelector, + children: [ + { + type: NodeType.RelativePseudoClass, + name: 'not', + children: [ + { + type: NodeType.SelectorList, + children: [ + { + type: NodeType.Selector, + children: [ + getRegularSelector('*'), + { + type: NodeType.ExtendedSelector, + children: [ + { + type: NodeType.RelativePseudoClass, + name: 'has', + children: [ + { + type: NodeType.SelectorList, + children: [ + { + type: NodeType.Selector, + children: [ + getRegularSelector('*'), + getRelativeExtendedWithSingleRegular('not', 'img'), // eslint-disable-line max-len + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }; + expect(parse(actual)).toEqual(expected); + }); + it('two not with simple selector next to each other', () => { const actual = ':not(span):not(p)'; const expected = [ diff --git a/test/selector/query-jsdom.test.ts b/test/selector/query-jsdom.test.ts index d7cb0cda..3f84fd2a 100644 --- a/test/selector/query-jsdom.test.ts +++ b/test/selector/query-jsdom.test.ts @@ -1268,6 +1268,8 @@ describe('combined pseudo-classes', () => { { actual: 'p:-abp-contains(inner paragraph):upward(div[id])', expected: 'div#inner' }, // -abp-contains upward not { actual: 'p:-abp-contains(inner paragraph):upward(div[id]:not([class]))', expected: 'div#parent' }, + // not(has(not)) + { actual: 'div.base:not(:has(:not(span, p)))', expected: 'div#inner' }, ]; test.each(successInputs)('%s', (input) => expectSuccessInput(input)); });