Angular unit test lazy loading and routing module

Viewed 99

Lets say i have a structure that looks like this:

app-routing.module.ts (there is a path /admin that leads to the admin page module)

{
    path: 'admin',
    loadChildren: () =>
      import('./components/admin-page/admin-page.module').then(
        (m) => m.AdminPageModule
    ),
},

And then the admin-page-routing.module.ts looks like this (/admin opens admin page component, /admin/temp-one opens temp one component)

const routes: Routes = [
{
    path: '',
    component: AdminPageComponent,
    children: [
      {
      path: 'temp-one',
      loadChildren: () =>
        import('./temp-one/temp-one.module').then(
          (m) => m.TempOneModule
        ),
      },
    ],
},
];

Teamcity is telling me that () => import ... is red/not unit tested. How do i unit test this part?

This is what i have tried so far:

admin-page.component.spec.ts

it('should navigate to temp-one', fakeAsync(() => {
    router.navigate(['temp-one']);
    tick();
    expect(location.path()).toEqual('/temp-one');
}));

But it is still red and not unit tested

0 Answers
Related