@@ -12,6 +12,7 @@ import {
1212import { NoopAnimationsModule , BrowserAnimationsModule } from '@angular/platform-browser/animations' ;
1313import { TestBed } from '@angular/core/testing' ;
1414import { render , fireEvent , screen } from '../src/public_api' ;
15+ import { Resolve , RouterModule } from '@angular/router' ;
1516
1617@Component ( {
1718 selector : 'atl-fixture' ,
@@ -296,3 +297,48 @@ describe('DebugElement', () => {
296297 expect ( view . debugElement . componentInstance ) . toBeInstanceOf ( FixtureComponent ) ;
297298 } ) ;
298299} ) ;
300+
301+ describe ( 'initialRoute' , ( ) => {
302+ @Component ( {
303+ standalone : true ,
304+ selector : 'atl-fixture2' ,
305+ template : `<button>Secondary Component</button>` ,
306+ } )
307+ class SecondaryFixtureComponent { }
308+
309+ @Component ( {
310+ standalone : true ,
311+ selector : 'atl-router-fixture' ,
312+ template : `<router-outlet></router-outlet>` ,
313+ imports : [ RouterModule ] ,
314+ } )
315+ class RouterFixtureComponent { }
316+
317+ @Injectable ( )
318+ class FixtureResolver implements Resolve < void > {
319+ public isResolved = false ;
320+
321+ public resolve ( ) {
322+ this . isResolved = true ;
323+ }
324+ }
325+
326+ it ( 'allows initially rendering a specific route to avoid triggering a resolver for the default route' , async ( ) => {
327+ const initialRoute = 'initial-route' ;
328+ const routes = [
329+ { path : initialRoute , component : FixtureComponent } ,
330+ { path : '**' , resolve : { data : FixtureResolver } , component : SecondaryFixtureComponent } ,
331+ ] ;
332+
333+ await render ( RouterFixtureComponent , {
334+ initialRoute,
335+ routes,
336+ providers : [ FixtureResolver ] ,
337+ } ) ;
338+ const resolver = TestBed . inject ( FixtureResolver ) ;
339+
340+ expect ( resolver . isResolved ) . toBe ( false ) ;
341+ expect ( screen . queryByText ( 'Secondary Component' ) ) . not . toBeInTheDocument ( ) ;
342+ expect ( screen . getByText ( 'button' ) ) . toBeInTheDocument ( ) ;
343+ } ) ;
344+ } ) ;
0 commit comments