@@ -17,6 +17,7 @@ describe('Add {N} schematic', () => {
1717 nsExtension : 'tns' ,
1818 webExtension : '' ,
1919 sample : false ,
20+ skipAutoGeneratedComponent : false
2021 } ;
2122
2223 let appTree : UnitTestTree ;
@@ -121,9 +122,49 @@ describe('Add {N} schematic', () => {
121122
122123 it ( 'should generate a sample shared component' , ( ) => {
123124 const { files } = appTree ;
125+ const appRoutingModuleContent = appTree . readContent ( '/foo/src/app/app-routing.module.tns.ts' ) ;
126+ const appComponentTemplate = appTree . readContent ( '/foo/src/app/app.component.tns.html' ) ;
124127 expect ( files ) . toContain ( '/foo/src/app/auto-generated/auto-generated.component.ts' ) ;
125128 expect ( files ) . toContain ( '/foo/src/app/auto-generated/auto-generated.component.html' ) ;
126129 expect ( files ) . toContain ( '/foo/src/app/auto-generated/auto-generated.component.tns.html' ) ;
130+ expect ( appRoutingModuleContent ) . toMatch (
131+ / i m p o r t { A u t o G e n e r a t e d C o m p o n e n t } f r o m ' .\/ a u t o - g e n e r a t e d \/ a u t o - g e n e r a t e d .c o m p o n e n t ' /
132+ ) ;
133+ expect ( appRoutingModuleContent ) . toMatch (
134+ / { \s + p a t h : ' a u t o - g e n e r a t e d ' , \s + c o m p o n e n t : A u t o G e n e r a t e d C o m p o n e n t , \s + } , / g
135+ ) ;
136+ expect ( appComponentTemplate ) . not . toContain (
137+ '<Label text="Entry Component works" textWrap="true"></Label>'
138+ ) ;
139+ } ) ;
140+ } ) ;
141+
142+ describe ( 'when the skipAutoGeneratedComponent flag is raised' , ( ) => {
143+ beforeEach ( ( ) => {
144+ const options = {
145+ ...defaultOptions ,
146+ skipAutoGeneratedComponent : true ,
147+ } ;
148+
149+ appTree = schematicRunner . runSchematic ( 'add-ns' , options , appTree ) ;
150+ } ) ;
151+
152+ it ( 'should not add a sample shared component' , ( ) => {
153+ const { files } = appTree ;
154+ const appRoutingModuleContent = appTree . readContent ( '/foo/src/app/app-routing.module.tns.ts' ) ;
155+ const appComponentTemplate = appTree . readContent ( '/foo/src/app/app.component.tns.html' ) ;
156+ expect ( files . includes ( '/foo/src/app/auto-generated/auto-generated.component.css' ) ) . toBeFalsy ( ) ;
157+ expect ( files . includes ( '/foo/src/app/auto-generated/auto-generated.component.html' ) ) . toBeFalsy ( ) ;
158+ expect ( files . includes ( '/foo/src/app/auto-generated/auto-generated.component.ts' ) ) . toBeFalsy ( ) ;
159+ expect ( appRoutingModuleContent ) . not . toMatch (
160+ / i m p o r t { A u t o G e n e r a t e d C o m p o n e n t } f r o m ' .\/ a u t o - g e n e r a t e d \/ a u t o - g e n e r a t e d .c o m p o n e n t ' /
161+ ) ;
162+ expect ( appRoutingModuleContent ) . toContain (
163+ 'export const routes: Routes = []'
164+ ) ;
165+ expect ( appComponentTemplate ) . toContain (
166+ '<Label text="Entry Component works" textWrap="true"></Label>'
167+ ) ;
127168 } ) ;
128169 } ) ;
129170
@@ -154,6 +195,13 @@ describe('Add {N} schematic', () => {
154195 expect ( files . includes ( '/foo/src/app/barcelona/player-detail/player-detail.component.html' ) ) . toBeTruthy ( ) ;
155196 expect ( files . includes ( '/foo/src/app/barcelona/player-detail/player-detail.component.tns.html' ) ) . toBeTruthy ( ) ;
156197 } ) ;
198+
199+ it ( 'should configure routing for redirection' , ( ) => {
200+ const appRoutingModuleContent = appTree . readContent ( '/foo/src/app/app-routing.module.tns.ts' ) ;
201+ expect ( appRoutingModuleContent ) . toMatch (
202+ / { \s + p a t h : ' ' , \s + r e d i r e c t T o : ' \/ p l a y e r s ' , \s + p a t h M a t c h : ' f u l l ' , \s + } , / g
203+ ) ;
204+ } ) ;
157205 } ) ;
158206} ) ;
159207
0 commit comments