Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for amp-date-display to build in unit tests #27431

Merged
merged 1 commit into from Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions extensions/amp-date-display/0.2/test/test-amp-date-display.js
Expand Up @@ -17,12 +17,16 @@
import '../../../amp-mustache/0.2/amp-mustache';
import '../amp-date-display';
import * as lolex from 'lolex';
import {waitForChildPromise} from '../../../../src/dom';
import {
waitForChildPromise,
whenUpgradedToCustomElement,
} from '../../../../src/dom';

describes.realWin(
'amp-date-display',
{
amp: {
runtimeOn: true,
extensions: ['amp-mustache:0.2', 'amp-date-display:0.2'],
},
},
Expand All @@ -32,6 +36,8 @@ describes.realWin(
let clock;

async function getRenderedData() {
await whenUpgradedToCustomElement(element);
await element.whenBuilt();
await waitForChildPromise(element, () => {
// The rendered container inserts a div element.
return element.querySelector('div');
Expand Down Expand Up @@ -74,7 +80,6 @@ describes.realWin(
});
element.appendChild(template);
element.setAttribute('layout', 'nodisplay');
win.document.body.appendChild(element);
});

afterEach(() => {
Expand All @@ -84,7 +89,7 @@ describes.realWin(
it('renders mustache template into element', async () => {
element.setAttribute('datetime', '2001-02-03T04:05:06.007Z');
element.setAttribute('display-in', 'UTC');
element.build();
win.document.body.appendChild(element);

const data = await getRenderedData();

Expand All @@ -111,7 +116,7 @@ describes.realWin(

it('does not rerender', async () => {
element.setAttribute('datetime', '2001-02-03T04:05:06.007Z');
element.build();
win.document.body.appendChild(element);

await getRenderedData();

Expand Down