UNPKG

@testing-library/react-native

Version:

Simple and complete React Native testing utilities that encourage good testing practices.

34 lines (32 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.waitForElementToBeRemoved = waitForElementToBeRemoved; var _errors = require("./helpers/errors"); var _waitFor = require("./wait-for"); function isRemoved(result) { return !result || Array.isArray(result) && !result.length; } async function waitForElementToBeRemoved(expectation, options) { // Created here so we get a nice stacktrace const timeoutError = new _errors.ErrorWithStack('Timed out in waitForElementToBeRemoved.', waitForElementToBeRemoved); // Elements have to be present initally and then removed. const initialElements = expectation(); if (isRemoved(initialElements)) { throw new _errors.ErrorWithStack('The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.', waitForElementToBeRemoved); } return await (0, _waitFor.waitFor)(() => { let result; try { result = expectation(); } catch { return initialElements; } if (!isRemoved(result)) { throw timeoutError; } return initialElements; }, options); } //# sourceMappingURL=wait-for-element-to-be-removed.js.map