The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/lib/utils/waitForElement.spec.ts

18 lines
622 B

import { waitForElement } from './waitForElement';
beforeEach(() => {
document.body.innerHTML = `<span class="ready" />`;
});
it('should return the element when it is already in the dom', async () => {
expect(await waitForElement('.ready')).toBe(document.querySelector('.ready'));
});
it('should await until the element be in the dom and return it', async () => {
setTimeout(() => {
const element = document.createElement('div');
element.setAttribute('class', 'not-ready');
document.body.appendChild(element);
}, 5);
expect(await waitForElement('.not-ready')).toBe(document.querySelector('.not-ready'));
});