Skip to content

Commit

Permalink
test: add a type test for p selectors (#12954)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored Aug 14, 2024
1 parent cc2eda2 commit ceed58e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test-d/NodeFor.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ declare const nodeFor: <Selector extends string>(
nodeFor('ignored ignored > ignored + ignored | a#ignore')
);
}
{
expectType<HTMLAnchorElement>(nodeFor('custom-element >>> a'));
expectNotType<Element>(nodeFor('custom-element >>> a'));
}
{
expectType<Element>(nodeFor('div ::-p-text(world)'));
expectNotType<HTMLDivElement>(nodeFor('div ::-p-text(world)'));
}
{
expectType<HTMLDivElement>(nodeFor('div ::-p-text(world) >>>> div'));
expectNotType<Element>(nodeFor('div ::-p-text(world) >>>> div'));
}
{
expectType<HTMLAnchorElement>(nodeFor('a::-p-text(Hello)'));
expectNotType<Element>(nodeFor('a::-p-text(Hello)'));
}
}
{
{
Expand Down
12 changes: 12 additions & 0 deletions test/src/queryhandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,18 @@ describe('Query handler tests', function () {
}
});

it('should work with puppeteer pseudo classes', async () => {
const {server, page} = await getTestState();
await page.goto(`${server.PREFIX}/p-selectors.html`);
using element = await page.$('button::-p-text(world)');
assert(element, 'Could not find element');
expect(
await element.evaluate(element => {
return element.id === 'b';
})
).toBeTruthy();
});

it('should work with deep combinators', async () => {
const {server, page} = await getTestState();
await page.goto(`${server.PREFIX}/p-selectors.html`);
Expand Down

0 comments on commit ceed58e

Please sign in to comment.