mirror of
https://github.com/jlengrand/open-wc.git
synced 2026-03-10 08:31:19 +00:00
fix(testing-helpers): remove deprecated flush
This commit is contained in:
committed by
Thomas Allmer
parent
af1a3ca9f9
commit
df077dcca7
@@ -71,16 +71,15 @@ expect(el.bar).to.equal('baz');
|
||||
```
|
||||
|
||||
## Timings
|
||||
If you need to wait for multiple elements to update you can use flush.
|
||||
By default it will be a timeout of 2ms but it will use a `window.flush` method if set.
|
||||
If you need to wait for multiple elements to update you can use `nextFrame`.
|
||||
|
||||
```js
|
||||
import { flush, aTimeout, html, litFixture } from '@open-wc/testing-helpers';
|
||||
import { nextFrame, aTimeout, html, litFixture } from '@open-wc/testing-helpers';
|
||||
|
||||
const el = await litFixture(html`<my-el .foo=${'bar'}></my-el>`);
|
||||
expect(el.foo).to.equal('bar');
|
||||
el.foo = 'baz';
|
||||
await flush();
|
||||
await nextFrame();
|
||||
// or as an alternative us timeout
|
||||
// await aTimeout(10); // would wait 10ms
|
||||
expect(el.shadowRoot.querySelector('#foo').innerText).to.equal('baz');
|
||||
|
||||
@@ -88,24 +88,3 @@ export async function oneEvent(element, eventName) {
|
||||
export async function nextFrame() {
|
||||
return new Promise(resolve => requestAnimationFrame(resolve));
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED:
|
||||
* Only useful with WCT pls use nextFrame as an alternative.
|
||||
* If used not within WCT it will fallback to a timout of 2ms.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function flush() {
|
||||
return new Promise(resolve => {
|
||||
if (window.flush) {
|
||||
window.flush(() => {
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user