mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
[@testing-library/dom] update to v7 (#43102)
Update types/testing-library__dom/wait-for-element-to-be-removed.d.ts Co-Authored-By: Sebastian Silbermann <silbermann.sebastian@gmail.com> Update pretty-format
This commit is contained in:
co-authored by
Sebastian Silbermann
parent
be2d773f49
commit
8dd4869771
+2
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for @testing-library/dom 6.14
|
||||
// Type definitions for @testing-library/dom 7.0
|
||||
// Project: https://github.com/testing-library/dom-testing-library
|
||||
// Definitions by: Alex Krolick <https://github.com/alexkrolick>
|
||||
// Kent C Dodds <https://github.com/kentcdodds>
|
||||
@@ -21,6 +21,7 @@ export * from './queries';
|
||||
export * from './query-helpers';
|
||||
export * from './screen';
|
||||
export * from './wait';
|
||||
export * from './wait-for';
|
||||
export * from './wait-for-dom-change';
|
||||
export * from './wait-for-element';
|
||||
export * from './wait-for-element-to-be-removed';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"pretty-format": "^24.3.0"
|
||||
"pretty-format": "^25.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { fireEvent, queries, screen, isInaccessible } from '@testing-library/dom';
|
||||
import { fireEvent, isInaccessible, queries, screen, waitFor, waitForElementToBeRemoved } from '@testing-library/dom';
|
||||
|
||||
const { getByText, queryByText, findByText, getAllByText, queryAllByText, findAllByText, queryAllByRole, queryByRole, findByRole } = queries;
|
||||
|
||||
@@ -73,3 +73,20 @@ function eventTest() {
|
||||
}
|
||||
fireEvent.click(element.firstChild);
|
||||
}
|
||||
|
||||
async function testWaitFors() {
|
||||
const element = document.createElement('div');
|
||||
|
||||
await waitFor(() => getByText(element, 'apple'));
|
||||
await waitFor(() => getAllByText(element, 'apple'));
|
||||
const result: HTMLSpanElement = await waitFor(() => getByText(element, 'apple'));
|
||||
if (!result) { // Use value
|
||||
throw new Error(`Can't find result`);
|
||||
}
|
||||
|
||||
element.innerHTML = '<span>apple</span>';
|
||||
|
||||
await waitForElementToBeRemoved(() => getByText(element, 'apple'));
|
||||
await waitForElementToBeRemoved(getByText(element, 'apple'));
|
||||
await waitForElementToBeRemoved(getAllByText(element, 'apple'));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export function waitForElementToBeRemoved<T>(
|
||||
callback: () => T,
|
||||
callback: (() => T) | T,
|
||||
options?: {
|
||||
container?: HTMLElement;
|
||||
timeout?: number;
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export function waitFor<T>(
|
||||
callback: () => T,
|
||||
options?: {
|
||||
container?: HTMLElement;
|
||||
timeout?: number;
|
||||
interval?: number;
|
||||
mutationObserverOptions?: MutationObserverInit;
|
||||
},
|
||||
): Promise<T>;
|
||||
Reference in New Issue
Block a user