@@ -2,7 +2,13 @@ import { normalize } from 'path';
22import { UnitTestTree } from '@angular-devkit/schematics/testing' ;
33
44import { Schema as NgAddOptions } from '../schema' ;
5- import { createTestRunner , createWorkspace , getFileContent , VERSION } from './utils' ;
5+ import {
6+ createTestRunner ,
7+ createWorkspace ,
8+ getFileContent ,
9+ skipConsoleLogging ,
10+ VERSION ,
11+ } from './utils' ;
612
713const workspaceOptions = {
814 name : 'ss-workspace' ,
@@ -30,67 +36,79 @@ describe('ng-add', () => {
3036 } ) ;
3137
3238 test ( 'should run ng-add' , async ( ) => {
33- const tree = await testRunner . runSchematic (
34- 'ng-add' ,
35- { project : 'ss-angular-cli-app' } ,
36- appTree ,
37- ) ;
39+ const tree = await skipConsoleLogging ( ( ) => {
40+ return testRunner . runSchematic < NgAddOptions > (
41+ 'ng-add' ,
42+ { project : 'ss-angular-cli-app' } ,
43+ appTree ,
44+ ) ;
45+ } ) ;
3846
3947 expect ( tree . files ) . toBeDefined ( ) ;
4048 } ) ;
4149
4250 test ( 'should add single-spa and single-spa-angular to dependencies' , async ( ) => {
43- const tree = await testRunner . runSchematic < NgAddOptions > (
44- 'ng-add' ,
45- { project : 'ss-angular-cli-app' } ,
46- appTree ,
47- ) ;
51+ const tree = await skipConsoleLogging ( ( ) => {
52+ return testRunner . runSchematic < NgAddOptions > (
53+ 'ng-add' ,
54+ { project : 'ss-angular-cli-app' } ,
55+ appTree ,
56+ ) ;
57+ } ) ;
4858
4959 const packageJSON = JSON . parse ( getFileContent ( tree , '/package.json' ) ) ;
5060 expect ( packageJSON . dependencies [ 'single-spa' ] ) . toBeDefined ( ) ;
5161 expect ( packageJSON . dependencies [ 'single-spa-angular' ] ) . toBeDefined ( ) ;
5262 } ) ;
5363
5464 test ( 'should add style-laoder to devDependencies' , async ( ) => {
55- const tree = await testRunner . runSchematic < NgAddOptions > (
56- 'ng-add' ,
57- { project : 'ss-angular-cli-app' } ,
58- appTree ,
59- ) ;
65+ const tree = await skipConsoleLogging ( ( ) => {
66+ return testRunner . runSchematic < NgAddOptions > (
67+ 'ng-add' ,
68+ { project : 'ss-angular-cli-app' } ,
69+ appTree ,
70+ ) ;
71+ } ) ;
6072
6173 const packageJSON = JSON . parse ( getFileContent ( tree , '/package.json' ) ) ;
6274 expect ( packageJSON . devDependencies [ 'style-loader' ] ) . toBeDefined ( ) ;
6375 } ) ;
6476
6577 test ( 'should add @angular-builders/custom-webpack to devDependencies' , async ( ) => {
66- const tree = await testRunner . runSchematic < NgAddOptions > (
67- 'ng-add' ,
68- { project : 'ss-angular-cli-app' } ,
69- appTree ,
70- ) ;
78+ const tree = await skipConsoleLogging ( ( ) => {
79+ return testRunner . runSchematic < NgAddOptions > (
80+ 'ng-add' ,
81+ { project : 'ss-angular-cli-app' } ,
82+ appTree ,
83+ ) ;
84+ } ) ;
7185
7286 const packageJSON = JSON . parse ( getFileContent ( tree , '/package.json' ) ) ;
7387 expect ( packageJSON . devDependencies [ '@angular-builders/custom-webpack' ] ) . toBeDefined ( ) ;
7488 } ) ;
7589
7690 test ( 'should add main-single-spa.ts' , async ( ) => {
77- const tree = await testRunner . runSchematic < NgAddOptions > (
78- 'ng-add' ,
79- { project : 'ss-angular-cli-app' } ,
80- appTree ,
81- ) ;
91+ const tree = await skipConsoleLogging ( ( ) => {
92+ return testRunner . runSchematic < NgAddOptions > (
93+ 'ng-add' ,
94+ { project : 'ss-angular-cli-app' } ,
95+ appTree ,
96+ ) ;
97+ } ) ;
8298
8399 expect (
84100 tree . files . indexOf ( '/projects/ss-angular-cli-app/src/main.single-spa.ts' ) ,
85101 ) . toBeGreaterThan ( - 1 ) ;
86102 } ) ;
87103
88104 test ( 'should use correct prefix for root' , async ( ) => {
89- const tree = await testRunner . runSchematic < NgAddOptions > (
90- 'ng-add' ,
91- { project : 'ss-angular-cli-app' } ,
92- appTree ,
93- ) ;
105+ const tree = await skipConsoleLogging ( ( ) => {
106+ return testRunner . runSchematic < NgAddOptions > (
107+ 'ng-add' ,
108+ { project : 'ss-angular-cli-app' } ,
109+ appTree ,
110+ ) ;
111+ } ) ;
94112
95113 const mainModuleContent = getFileContent (
96114 tree ,
@@ -100,11 +118,13 @@ describe('ng-add', () => {
100118 } ) ;
101119
102120 test ( 'should not add router dependencies' , async ( ) => {
103- const tree = await testRunner . runSchematic < NgAddOptions > (
104- 'ng-add' ,
105- { project : 'ss-angular-cli-app' , routing : false } ,
106- appTree ,
107- ) ;
121+ const tree = await skipConsoleLogging ( ( ) => {
122+ return testRunner . runSchematic < NgAddOptions > (
123+ 'ng-add' ,
124+ { project : 'ss-angular-cli-app' , routing : false } ,
125+ appTree ,
126+ ) ;
127+ } ) ;
108128
109129 const mainModuleContent = getFileContent (
110130 tree ,
@@ -114,11 +134,13 @@ describe('ng-add', () => {
114134 } ) ;
115135
116136 test ( 'should add router dependencies' , async ( ) => {
117- const tree = await testRunner . runSchematic < NgAddOptions > (
118- 'ng-add' ,
119- { project : 'ss-angular-cli-app' , routing : true } ,
120- appTree ,
121- ) ;
137+ const tree = await skipConsoleLogging ( ( ) => {
138+ return testRunner . runSchematic < NgAddOptions > (
139+ 'ng-add' ,
140+ { project : 'ss-angular-cli-app' , routing : true } ,
141+ appTree ,
142+ ) ;
143+ } ) ;
122144
123145 const mainModuleContent = getFileContent (
124146 tree ,
@@ -128,11 +150,13 @@ describe('ng-add', () => {
128150 } ) ;
129151
130152 test ( 'should modify angular.json' , async ( ) => {
131- const tree = await testRunner . runSchematic < NgAddOptions > (
132- 'ng-add' ,
133- { routing : true , project : 'ss-angular-cli-app' } ,
134- appTree ,
135- ) ;
153+ const tree = await skipConsoleLogging ( ( ) => {
154+ return testRunner . runSchematic < NgAddOptions > (
155+ 'ng-add' ,
156+ { routing : true , project : 'ss-angular-cli-app' } ,
157+ appTree ,
158+ ) ;
159+ } ) ;
136160
137161 const angularJSON = JSON . parse ( getFileContent ( tree , '/angular.json' ) ) ;
138162 const ssApp = angularJSON . projects [ 'ss-angular-cli-app' ] ;
@@ -155,11 +179,13 @@ describe('ng-add', () => {
155179 } ) ;
156180
157181 test ( 'should add build:single-spa:PROJECT_NAME npm script' , async ( ) => {
158- const tree = await testRunner . runSchematic < NgAddOptions > (
159- 'ng-add' ,
160- { project : 'ss-angular-cli-app' , routing : true } ,
161- appTree ,
162- ) ;
182+ const tree = await skipConsoleLogging ( ( ) => {
183+ return testRunner . runSchematic < NgAddOptions > (
184+ 'ng-add' ,
185+ { project : 'ss-angular-cli-app' , routing : true } ,
186+ appTree ,
187+ ) ;
188+ } ) ;
163189
164190 const packageJSON = JSON . parse ( getFileContent ( tree , '/package.json' ) ) ;
165191 expect ( packageJSON . scripts [ 'build:single-spa:ss-angular-cli-app' ] ) . toBeDefined ( ) ;
0 commit comments