Skip to content

Commit

Permalink
AG-16783 add few not(has(not)) tests
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit c38f3a00df786c19e03f30ebf734539bea60349f
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Oct 4 17:05:54 2022 +0300

    add few not(has(not)) tests
  • Loading branch information
slavaleleka committed Oct 5, 2022
1 parent 1e77dac commit 92d6b8b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/selector/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions test/selector/query-jsdom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand Down

0 comments on commit 92d6b8b

Please sign in to comment.