angular-testing-recipes icon indicating copy to clipboard operation
angular-testing-recipes copied to clipboard

how to test components that use import (dinamic import) inside component ?

Open AlonsoK28 opened this issue 3 years ago • 0 comments

you can provide to make the test for components using import inside a component? (no router module)

example:

async loadImportXlsx(){

    // avoid user throttling
    if (this.isLoadingImportXlsx) return;

    this.isLoadingImportXlsx = true;

    const config: MatDialogConfig = {
      width: '85%',
      height: '95%',
      disableClose: true,
      data: {
        currentDomain: this.selectedDomain
      } 
    };
    
    // how test this line?
    const lazyComponent = await import('@pages/import/import.component');

    const dialogRef = this.dialog.open(lazyComponent.ImportComponent, config);
    dialogRef
    .beforeClosed()
    .subscribe(data => this.title.setTitle(this.dashboardTitle));

    setTimeout(() => {
      this.isLoadingImportXlsx = false;
    }, 1300);
  }

this code gets a ngModule using lazy load (with import) and then open it inside a new Material Dialog

AlonsoK28 avatar Nov 14 '22 04:11 AlonsoK28