fix(testing-helpers): remove deprecated flush

This commit is contained in:
Pascal Schilp
2018-12-21 20:43:07 +01:00
committed by Thomas Allmer
parent af1a3ca9f9
commit df077dcca7
2 changed files with 3 additions and 25 deletions

View File

@@ -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');

View File

@@ -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);
}
});
}