@@ -25,27 +25,30 @@ describe('layout', () => {
2525
2626 const workspaceOptions : WorkspaceOptions = {
2727 name : 'workspace' ,
28- version : '6 .0.0'
28+ version : '16 .0.0'
2929 } ;
3030
3131 const options : any = {
3232 layout : 'side-nav-outer-toolbar' ,
3333 resolveConflicts : 'override' ,
34- globalNgCliVersion : '^12 .2.0'
34+ globalNgCliVersion : '^16 .2.0'
3535 } ;
3636
3737 const angularSchematicsCollection = require . resolve ( '../../node_modules/@schematics/angular/collection.json' ) ;
38- const schematicRunner = new SchematicTestRunner ( '@schematics/angular' , angularSchematicsCollection ) ;
38+ const schematicRunner = new SchematicTestRunner (
39+ '@schematics/angular' ,
40+ angularSchematicsCollection ,
41+ ) ;
3942 let appTree : UnitTestTree ;
4043
4144 beforeEach ( async ( ) => {
42- appTree = await schematicRunner . runSchematicAsync ( 'workspace' , workspaceOptions ) . toPromise ( ) ;
43- appTree = await schematicRunner . runSchematicAsync ( 'application' , appOptions , appTree ) . toPromise ( ) ;
45+ appTree = await schematicRunner . runSchematic ( 'workspace' , workspaceOptions ) ;
46+ appTree = await schematicRunner . runSchematic ( 'application' , appOptions , appTree ) ;
4447 } ) ;
4548
4649 it ( 'should add layout with override' , async ( ) => {
4750 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
48- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
51+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
4952
5053 expect ( tree . files )
5154 . toContain ( '/devextreme.json' ) ;
@@ -108,12 +111,6 @@ describe('layout', () => {
108111 'ChangePasswordFormModule, ' +
109112 'LoginFormModule }' ) ;
110113
111- const testContent = tree . readContent ( '/e2e/src/app.e2e-spec.ts' ) ;
112- expect ( testContent ) . toMatch ( / ' W e l c o m e t o T e s t A p p ! ' / ) ;
113-
114- const testUtilsContent = tree . readContent ( '/e2e/src/app.po.ts' ) ;
115- expect ( testUtilsContent ) . toMatch ( / ' a p p - r o o t .d x - d r a w e r - c o n t e n t .d x - c a r d p : n t h - c h i l d \( 2 \) ' / ) ;
116-
117114 const appContent = tree . readContent ( '/src/app/app.component.ts' ) ;
118115 expect ( appContent ) . toContain ( 'templateUrl: \'./app.component.html\',' ) ;
119116 expect ( appContent ) . toContain ( 'styleUrls: [\'./app.component.scss\']' ) ;
@@ -127,7 +124,7 @@ describe('layout', () => {
127124
128125 it ( 'should add npm scripts' , async ( ) => {
129126 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
130- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
127+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
131128 const packageConfig = JSON . parse ( tree . readContent ( 'package.json' ) ) ;
132129 expect ( packageConfig . scripts [ 'build-themes' ] ) . toBe ( 'devextreme build' ) ;
133130 expect ( packageConfig . scripts [ 'postinstall' ] ) . toBe ( 'npm run build-themes' ) ;
@@ -142,7 +139,7 @@ describe('layout', () => {
142139 } ) ;
143140
144141 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
145- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
142+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
146143 const navigationMenu = tree . readContent (
147144 '/src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts' ) ;
148145
@@ -160,7 +157,7 @@ describe('layout', () => {
160157 } ) ;
161158
162159 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
163- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
160+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
164161 const packageConfig = JSON . parse ( tree . readContent ( 'package.json' ) ) ;
165162 expect ( packageConfig . scripts [ 'origin-build-themes' ] ) . toBe ( 'prev value 1' ) ;
166163 expect ( packageConfig . scripts [ 'origin-postinstall' ] ) . toBe ( 'prev value 2' ) ;
@@ -170,26 +167,26 @@ describe('layout', () => {
170167
171168 it ( 'should add angular/cdk dependency' , async ( ) => {
172169 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
173- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
170+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
174171 const packageConfig = JSON . parse ( tree . readContent ( 'package.json' ) ) ;
175172
176173 expect ( packageConfig . dependencies [ '@angular/cdk' ] ) . toBeDefined ( ) ;
177174 } ) ;
178175
179176 it ( 'should choose angular/cdk version such as angular/cli' , async ( ) => {
180177 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
181- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
178+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
182179 const packageConfig = JSON . parse ( tree . readContent ( 'package.json' ) ) ;
183180
184- expect ( packageConfig . dependencies [ '@angular/cdk' ] ) . toBe ( '~12 .2.0' ) ;
181+ expect ( packageConfig . dependencies [ '@angular/cdk' ] ) . toBe ( '~16 .2.0' ) ;
185182 } ) ;
186183
187184 it ( 'should update budgets if updateBudgets option is true' , async ( ) => {
188185 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
189- const tree = await runner . runSchematicAsync ( 'add-layout' , {
186+ const tree = await runner . runSchematic ( 'add-layout' , {
190187 ...options ,
191188 updateBudgets : true
192- } , appTree ) . toPromise ( ) ;
189+ } , appTree ) ;
193190
194191 const angularContent = JSON . parse ( tree . readContent ( '/angular.json' ) ) ;
195192 const budgets = angularContent . projects . testApp . architect . build . configurations . production . budgets ;
@@ -204,7 +201,7 @@ describe('layout', () => {
204201
205202 it ( 'should not update budgets if updateBudgets option is not defined or false' , async ( ) => {
206203 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
207- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
204+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
208205
209206 const angularContent = JSON . parse ( tree . readContent ( '/angular.json' ) ) ;
210207 const budgets = angularContent . projects . testApp . architect . build . configurations . production . budgets ;
@@ -222,7 +219,7 @@ describe('layout', () => {
222219 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
223220
224221 options . resolveConflicts = 'createNew' ;
225- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
222+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
226223
227224 expect ( tree . files ) . toContain ( '/src/app/app1.component.ts' ) ;
228225
@@ -243,14 +240,14 @@ describe('layout', () => {
243240 } ) ;
244241
245242 it ( 'should add routing to layout' , async ( ) => {
246- let newAppTree = await schematicRunner . runSchematicAsync ( 'workspace' , workspaceOptions ) . toPromise ( ) ;
243+ let newAppTree = await schematicRunner . runSchematic ( 'workspace' , workspaceOptions ) ;
247244
248245 appOptions . routing = false ;
249- newAppTree = await schematicRunner . runSchematicAsync (
250- 'application' , appOptions , newAppTree ) . toPromise ( ) ;
246+ newAppTree = await schematicRunner . runSchematic (
247+ 'application' , appOptions , newAppTree ) ;
251248
252249 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
253- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
250+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
254251
255252 expect ( tree . files ) . toContain ( '/src/app/app-routing.module.ts' ) ;
256253 const moduleContent = tree . readContent ( '/src/app/app-routing.module.ts' ) ;
@@ -269,24 +266,24 @@ describe('layout', () => {
269266 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
270267 options . layout = 'side-nav-inner-toolbar' ;
271268 options . resolveConflicts = 'override' ;
272- const tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
269+ const tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
273270 const content = tree . readContent ( '/src/app/app.component.html' ) ;
274271
275272 expect ( content ) . toContain ( 'app-side-nav-inner-toolbar title="{{appInfo.title}}"' ) ;
276273 } ) ;
277274
278275 it ( 'should consider the `project` option' , async ( ) => {
279- appTree = await schematicRunner . runSchematicAsync ( 'application' , {
276+ appTree = await schematicRunner . runSchematic ( 'application' , {
280277 ...appOptions ,
281278 name : 'testApp2' ,
282279 projectRoot : 'projects/testApp2'
283- } , appTree ) . toPromise ( ) ;
280+ } , appTree ) ;
284281
285282 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
286- const tree = await runner . runSchematicAsync ( 'add-layout' , {
283+ const tree = await runner . runSchematic ( 'add-layout' , {
287284 ...options ,
288285 project : 'testApp2'
289- } , appTree ) . toPromise ( ) ;
286+ } , appTree ) ;
290287
291288 expect ( tree . files )
292289 . toContain ( '/devextreme.json' ) ;
@@ -295,19 +292,19 @@ describe('layout', () => {
295292 } ) ;
296293
297294 it ( 'should merge build commands in devextreme.json file' , async ( ) => {
298- appTree = await schematicRunner . runSchematicAsync ( 'application' , {
295+ appTree = await schematicRunner . runSchematic ( 'application' , {
299296 ...appOptions ,
300297 name : 'testApp2' ,
301298 prefix : 'app2' ,
302299 projectRoot : 'projects/testApp2'
303- } , appTree ) . toPromise ( ) ;
300+ } , appTree ) ;
304301
305302 const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
306- let tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
307- tree = await runner . runSchematicAsync ( 'add-layout' , {
303+ let tree = await runner . runSchematic ( 'add-layout' , options , appTree ) ;
304+ tree = await runner . runSchematic ( 'add-layout' , {
308305 ...options ,
309306 project : 'testApp2'
310- } , appTree ) . toPromise ( ) ;
307+ } , appTree ) ;
311308
312309 const appContent = tree . readContent ( 'projects/testApp2/src/app/app.component.ts' ) ;
313310 expect ( appContent ) . toContain ( 'selector: \'app2-root\',' ) ;
@@ -316,25 +313,4 @@ describe('layout', () => {
316313 expect ( content ) . toContain ( '"inputFile": "src/themes/metadata.base.json",' ) ;
317314 expect ( content ) . toContain ( '"inputFile": "projects/testApp2/src/themes/metadata.base.json",' ) ;
318315 } ) ;
319-
320- it ( 'should add e2e tests only for default project' , async ( ) => {
321- appTree = await schematicRunner . runSchematicAsync ( 'application' , {
322- ...appOptions ,
323- name : 'testApp2' ,
324- projectRoot : 'projects/testApp2'
325- } , appTree ) . toPromise ( ) ;
326-
327- const runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
328- let tree = await runner . runSchematicAsync ( 'add-layout' , options , appTree ) . toPromise ( ) ;
329- tree = await runner . runSchematicAsync ( 'add-layout' , {
330- ...options ,
331- project : 'testApp2'
332- } , appTree ) . toPromise ( ) ;
333-
334- const testContent = tree . readContent ( '/e2e/src/app.e2e-spec.ts' ) ;
335- expect ( testContent ) . toContain ( 'Welcome to TestApp!' ) ;
336-
337- const testUtilsContent = tree . readContent ( '/e2e/src/app.po.ts' ) ;
338- expect ( testUtilsContent ) . toMatch ( / ' a p p - r o o t .d x - d r a w e r - c o n t e n t .d x - c a r d p : n t h - c h i l d \( 2 \) ' / ) ;
339- } ) ;
340316} ) ;
0 commit comments