Skip to content

Commit

Permalink
Restore timeout stub before test
Browse files Browse the repository at this point in the history
  • Loading branch information
maier49 committed Jun 24, 2019
1 parent 66e46ba commit e028563
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/core/unit/registerCustomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { v, w } from '../../../src/core/vdom';
import register, { create, CustomElementChildType } from '../../../src/core/registerCustomElement';
import { createResolvers } from '../support/util';
import { ThemedMixin, theme } from '../../../src/core/mixins/Themed';
import { waitFor } from './waitFor';

const { describe, it, beforeEach, afterEach, before } = intern.getInterface('bdd');
const { assert } = intern.getPlugin('chai');
Expand Down Expand Up @@ -373,7 +372,8 @@ describe('registerCustomElement', () => {
assert.equal(display, 'block');
});

it('handles children being appended as document is still loading', async () => {
it('handles children being appended as document is still loading', () => {
resolvers.restore();
register(DelayedChildrenWidget);

Object.defineProperty(document, 'readyState', {
Expand All @@ -397,10 +397,17 @@ describe('registerCustomElement', () => {
child = document.createTextNode('bar');
element!.appendChild(child);

waitFor(
() =>
element!.outerHTML ===
'<delayed-children-element style="display: block;"><div><div data-key="child-0">foo</div><div data-key="child-1">bar</div></div></delayed-children-element>'
);
return new Promise((resolve, reject) => {
setTimeout(() => {
if (
element!.outerHTML !==
'<delayed-children-element style="display: block;"><div><div data-key="child-0">foo</div><div data-key="child-1">bar</div></div></delayed-children-element>'
) {
reject(`${element!.outerHTML}\n That shit aint right`);
}

resolve();
});
});
});
});

0 comments on commit e028563

Please sign in to comment.