Skip to content

Commit 8c5c05d

Browse files
test: add type tests for within (#1044)
1 parent f27d14c commit 8c5c05d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

types/__tests__/type-tests.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
waitForElementToBeRemoved,
1111
MatcherOptions,
1212
BoundFunctions,
13+
within,
1314
} from '@testing-library/dom'
1415

1516
const {
@@ -228,6 +229,18 @@ export async function testWaitFors() {
228229
await waitFor(async () => {})
229230
}
230231

232+
export async function testWithin() {
233+
const container = within(document.body)
234+
container.queryAllByLabelText('Some label')
235+
236+
container.getByText('Click me')
237+
container.getByText<HTMLButtonElement>('Click me')
238+
container.getAllByText<HTMLButtonElement>('Click me')
239+
240+
await container.findByRole('button', {name: /click me/i})
241+
container.getByRole<HTMLButtonElement>('button', {name: /click me/i})
242+
}
243+
231244
/*
232245
eslint
233246
@typescript-eslint/no-unnecessary-condition: "off",

0 commit comments

Comments
 (0)