3 * Copyright 2024 Google Inc.
4 * SPDX-License-Identifier: Apache-2.0
6 import type {NodeFor} from 'puppeteer';
7 import {expectType, expectNotType} from 'tsd';
9 declare const nodeFor: <Selector extends string>(
11 ) => NodeFor<Selector>;
15 expectType<HTMLTableRowElement>(
17 '[data-testid="my-component"] div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div tbody tr',
20 expectNotType<Element>(
22 '[data-testid="my-component"] div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div tbody tr',
27 expectType<HTMLAnchorElement>(nodeFor('a'));
28 expectNotType<Element>(nodeFor('a'));
31 expectType<HTMLAnchorElement>(nodeFor('a#ignored'));
32 expectNotType<Element>(nodeFor('a#ignored'));
35 expectType<HTMLAnchorElement>(nodeFor('a.ignored'));
36 expectNotType<Element>(nodeFor('a.ignored'));
39 expectType<HTMLAnchorElement>(nodeFor('a[ignored'));
40 expectNotType<Element>(nodeFor('a[ignored'));
43 expectType<HTMLAnchorElement>(nodeFor('a:ignored'));
44 expectNotType<Element>(nodeFor('a:ignored'));
47 expectType<HTMLAnchorElement>(nodeFor('ignored a'));
48 expectNotType<Element>(nodeFor('ignored a'));
51 expectType<HTMLAnchorElement>(nodeFor('ignored a#ignored'));
52 expectNotType<Element>(nodeFor('ignored a#ignored'));
55 expectType<HTMLAnchorElement>(nodeFor('ignored a.ignored'));
56 expectNotType<Element>(nodeFor('ignored a.ignored'));
59 expectType<HTMLAnchorElement>(nodeFor('ignored a[ignored'));
60 expectNotType<Element>(nodeFor('ignored a[ignored'));
63 expectType<HTMLAnchorElement>(nodeFor('ignored a:ignored'));
64 expectNotType<Element>(nodeFor('ignored a:ignored'));
67 expectType<HTMLAnchorElement>(nodeFor('ignored > a'));
68 expectNotType<Element>(nodeFor('ignored > a'));
71 expectType<HTMLAnchorElement>(nodeFor('ignored > a#ignored'));
72 expectNotType<Element>(nodeFor('ignored > a#ignored'));
75 expectType<HTMLAnchorElement>(nodeFor('ignored > a.ignored'));
76 expectNotType<Element>(nodeFor('ignored > a.ignored'));
79 expectType<HTMLAnchorElement>(nodeFor('ignored > a[ignored'));
80 expectNotType<Element>(nodeFor('ignored > a[ignored'));
83 expectType<HTMLAnchorElement>(nodeFor('ignored > a:ignored'));
84 expectNotType<Element>(nodeFor('ignored > a:ignored'));
87 expectType<HTMLAnchorElement>(nodeFor('ignored + a'));
88 expectNotType<Element>(nodeFor('ignored + a'));
91 expectType<HTMLAnchorElement>(nodeFor('ignored ~ a'));
92 expectNotType<Element>(nodeFor('ignored ~ a'));
95 expectType<HTMLAnchorElement>(nodeFor('ignored | a'));
96 expectNotType<Element>(nodeFor('ignored | a'));
99 expectType<HTMLAnchorElement>(
100 nodeFor('ignored ignored > ignored + ignored | a#ignore'),
102 expectNotType<Element>(
103 nodeFor('ignored ignored > ignored + ignored | a#ignore'),
107 expectType<HTMLAnchorElement>(nodeFor('custom-element >>> a'));
108 expectNotType<Element>(nodeFor('custom-element >>> a'));
111 expectType<Element>(nodeFor('div ::-p-text(world)'));
112 expectNotType<HTMLDivElement>(nodeFor('div ::-p-text(world)'));
115 expectType<HTMLDivElement>(nodeFor('div ::-p-text(world) >>>> div'));
116 expectNotType<Element>(nodeFor('div ::-p-text(world) >>>> div'));
119 expectType<HTMLAnchorElement>(nodeFor('a::-p-text(Hello)'));
120 expectNotType<Element>(nodeFor('a::-p-text(Hello)'));
123 expectType<HTMLAnchorElement>(nodeFor('a:is([href], [href])'));
124 expectNotType<Element>(nodeFor('a:is([href], [href])'));
129 expectType<Element>(nodeFor(''));
132 expectType<Element>(nodeFor('#ignored'));
135 expectType<Element>(nodeFor('.ignored'));
138 expectType<Element>(nodeFor('[ignored'));
141 expectType<Element>(nodeFor(':ignored'));
144 expectType<Element>(nodeFor('ignored #ignored'));
147 expectType<Element>(nodeFor('ignored .ignored'));
150 expectType<Element>(nodeFor('ignored [ignored'));
153 expectType<Element>(nodeFor('ignored :ignored'));
156 expectType<Element>(nodeFor('ignored > #ignored'));
159 expectType<Element>(nodeFor('ignored > .ignored'));
162 expectType<Element>(nodeFor('ignored > [ignored'));
165 expectType<Element>(nodeFor('ignored > :ignored'));
168 expectType<Element>(nodeFor('ignored + #ignored'));
171 expectType<Element>(nodeFor('ignored ~ #ignored'));
174 expectType<Element>(nodeFor('ignored | #ignored'));
178 nodeFor('ignored ignored > ignored ~ ignored + ignored | #ignored'),