Skip to content

Commit

Permalink
test: update tests due to lazy loading dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Rong Sen Ng (motss) <wes.ngrongsen@gmail.com>
  • Loading branch information
motss committed Feb 20, 2022
1 parent b3c32f2 commit c201c14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../../date-picker/app-date-picker';
import '../../date-picker-dialog/app-date-picker-dialog';

import type { Button } from '@material/mwc-button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '../../date-picker-input-surface/app-date-picker-input-surface';
import '../../date-picker/app-date-picker';
import '../../date-picker-input/app-date-picker-input';
import '../../date-picker-input-surface/app-date-picker-input-surface';

import type { Button } from '@material/mwc-button';
import { expect, fixture, html } from '@open-wc/testing';
Expand Down
19 changes: 13 additions & 6 deletions src/date-picker-input/date-picker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,19 @@ export class DatePickerInput extends ElementMixin(DatePickerMixin(DatePickerMinM
}

async #lazyLoad() {
const pickerTask = globalThis.customElements.whenDefined(appDatePickerName);
const surfaceTask = globalThis.customElements.whenDefined(appDatePickerInputSurfaceName);

await this.lazyLoad?.();
await pickerTask;
await surfaceTask;
const deps = [
appDatePickerName,
appDatePickerInputSurfaceName,
];

if (deps.some(n => globalThis.customElements.get(n) == null)) {
const tasks = deps.map(
n => globalThis.customElements.whenDefined(n)
);

await this.lazyLoad?.();
await Promise.all(tasks);
}

this._rendered = true;
}
Expand Down

0 comments on commit c201c14

Please sign in to comment.