Skip to content

Commit

Permalink
fix: allow empty fixture (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlockhart authored Nov 16, 2023
1 parent e9247f3 commit 0985ad5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/browser/fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ function getComposedChildren(node) {

async function waitForElem(elem, awaitLoadingComplete = true) {

if (!elem) return;

const doWait = async() => {

const update = elem?.updateComplete;
const update = elem.updateComplete;
if (typeof update === 'object' && Promise.resolve(update) === update) {
await update;
await nextFrame();
}

if (awaitLoadingComplete && typeof elem?.getLoadingComplete === 'function') {
if (awaitLoadingComplete && typeof elem.getLoadingComplete === 'function') {
await elem.getLoadingComplete();
await nextFrame();
}
Expand Down
4 changes: 4 additions & 0 deletions test/browser/fixture.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ describe('fixture', () => {
}
});

it('should handle an empty fixture', async() => {
await fixture(html``);
});

it('should wait for slow element at fixture root', async() => {
const finishedPromise = fixture(`<${slowElem} id="slow"></${slowElem}>`)
.then((elem) => elem.finished);
Expand Down

0 comments on commit 0985ad5

Please sign in to comment.