@@ -84,6 +84,20 @@ describe('route utils', () => {
8484 expect ( newContent ) . toEqual ( `import { Router } from '@angular/router';\n` ) ;
8585 } ) ;
8686 } ) ;
87+ it ( 'inserts subcomponent in win32 environment' , ( ) => {
88+ let content = './level1\\level2/level2.component' ;
89+ return nru . insertImport ( sourceFile , 'level2' , content ) . apply ( )
90+ . then ( ( ) => readFile ( sourceFile , 'utf8' ) )
91+ . then ( newContent => {
92+ if ( process . platform . startsWith ( 'win' ) ) {
93+ expect ( newContent ) . toEqual (
94+ `import { level2 } from './level1/level2/level2.component';\n` ) ;
95+ } else {
96+ expect ( newContent ) . toEqual (
97+ `import { level2 } from './level1\\level2/level2.component';\n` ) ;
98+ }
99+ } ) ;
100+ } ) ;
87101 } ) ;
88102
89103 describe ( 'bootstrapItem' , ( ) => {
@@ -124,7 +138,7 @@ describe('route utils', () => {
124138 . then ( content => {
125139 expect ( content ) . toEqual (
126140 `import routes from './routes';
127- import { provideRouter } from '@angular/router';
141+ import { provideRouter } from '@angular/router';
128142 bootstrap(AppComponent, [ provideRouter(routes) ]);` ) ;
129143 } ) ;
130144 } ) ;
@@ -299,7 +313,7 @@ export default [
299313 children: [
300314 { path: 'about', component: AboutComponent,
301315 children: [
302- { path: 'details', component: DetailsComponent },
316+ { path: 'details', component: DetailsComponent },
303317 { path: 'more', component: MoreComponent }
304318 ]
305319 }
@@ -327,7 +341,7 @@ export default [
327341 children: [
328342 { path: 'more', component: MoreComponent,
329343 children: [
330- { path: 'sections', component: SectionsComponent }
344+ { path: 'sections', component: SectionsComponent }
331345 ]
332346 }
333347 ]
@@ -359,7 +373,7 @@ export default [
359373 { path: 'main', component: MainComponent }
360374 { path: 'home', component: HomeComponent,
361375 children: [
362- { path: 'about/:id', component: AboutComponent_1 },
376+ { path: 'about/:id', component: AboutComponent_1 },
363377 { path: 'about', component: AboutComponent }
364378 ]
365379 }
@@ -447,7 +461,7 @@ export default [
447461export default [
448462 { path: 'home', component: HomeComponent,
449463 children: [
450- { path: 'trap-queen', component: TrapQueenComponent },
464+ { path: 'trap-queen', component: TrapQueenComponent },
451465 { path: 'about', component: AboutComponent,
452466 children: [
453467 { path: 'more', component: MoreComponent }
@@ -478,7 +492,7 @@ import { HomeComponent as HomeComponent_1 } from './app/home/home/home.component
478492export default [
479493 { path: 'home', component: HomeComponent,
480494 children: [
481- { path: 'home', component: HomeComponent_1 }
495+ { path: 'home', component: HomeComponent_1 }
482496 ]
483497 }
484498];` ;
@@ -487,7 +501,7 @@ export default [
487501 } ) ;
488502 it ( 'throws error if components collide and there is repitition' , ( ) => {
489503 let editedFile = new InsertChange ( routesFile , 16 ,
490- `\n { path: 'about', component: AboutComponent,
504+ `\n { path: 'about', component: AboutComponent,
491505 children: [
492506 { path: 'details/:id', component: DetailsComponent_1 },
493507 { path: 'details', component: DetailsComponent }
@@ -543,7 +557,7 @@ import { DetailsComponent as DetailsComponent_1 } from './app/about/description/
543557export default [
544558 { path: 'home', component: HomeComponent,
545559 children: [
546- { path: 'more', component: MoreComponent, canDeactivate: [ MyGuard ], useAsDefault: true }
560+ { path: 'more', component: MoreComponent, canDeactivate: [ MyGuard ], useAsDefault: true }
547561 ]
548562 }
549563];`
0 commit comments