@@ -129,6 +129,75 @@ describe("cli-config schematic", () => {
129129 expect ( headContentsRegex . exec ( content ) ! . pop ( ) ) . toContain ( "family=Material+Icons" ) ;
130130 } ) ;
131131
132+ it ( "should add Titillium and Material Icons when build options do not have index" , async ( ) => {
133+ const targetFile = "/src/index.html" ;
134+ const ngJsonWithoutBuildIndex = {
135+ projects : {
136+ testProj : {
137+ root : "" ,
138+ sourceRoot,
139+ architect : {
140+ build : {
141+ options : {
142+ main : `${ sourceRoot } /main.ts` ,
143+ polyfills : `${ sourceRoot } /polyfills.ts` ,
144+ scripts : [ ]
145+ }
146+ } ,
147+ serve : { } ,
148+ test : { }
149+ }
150+ }
151+ } ,
152+ version : 1
153+ } ;
154+
155+ tree . overwrite ( "/angular.json" , JSON . stringify ( ngJsonWithoutBuildIndex ) ) ;
156+ await runner . runSchematic ( "cli-config" , { } , tree ) ;
157+
158+ const content = tree . readContent ( targetFile ) ;
159+ const headContentsRegex = / (?: < h e a d > ) ( [ \s \S ] * ) (?: < \/ h e a d > ) / ;
160+ expect ( headContentsRegex . test ( content ) ) . toBeTruthy ( ) ;
161+ expect ( headContentsRegex . exec ( content ) ! . pop ( ) ) . toContain ( "family=Titillium+Web" ) ;
162+ expect ( headContentsRegex . exec ( content ) ! . pop ( ) ) . toContain ( "family=Material+Icons" ) ;
163+ } ) ;
164+
165+ it ( "should add Titillium and Material Icons when build index is an object input" , async ( ) => {
166+ const targetFile = "/src/index.html" ;
167+ const ngJsonWithIndexObject = {
168+ projects : {
169+ testProj : {
170+ root : "" ,
171+ sourceRoot,
172+ architect : {
173+ build : {
174+ options : {
175+ main : `${ sourceRoot } /main.ts` ,
176+ polyfills : `${ sourceRoot } /polyfills.ts` ,
177+ scripts : [ ] ,
178+ index : {
179+ input : `${ sourceRoot } /index.html`
180+ }
181+ }
182+ } ,
183+ serve : { } ,
184+ test : { }
185+ }
186+ }
187+ } ,
188+ version : 1
189+ } ;
190+
191+ tree . overwrite ( "/angular.json" , JSON . stringify ( ngJsonWithIndexObject ) ) ;
192+ await runner . runSchematic ( "cli-config" , { } , tree ) ;
193+
194+ const content = tree . readContent ( targetFile ) ;
195+ const headContentsRegex = / (?: < h e a d > ) ( [ \s \S ] * ) (?: < \/ h e a d > ) / ;
196+ expect ( headContentsRegex . test ( content ) ) . toBeTruthy ( ) ;
197+ expect ( headContentsRegex . exec ( content ) ! . pop ( ) ) . toContain ( "family=Titillium+Web" ) ;
198+ expect ( headContentsRegex . exec ( content ) ! . pop ( ) ) . toContain ( "family=Material+Icons" ) ;
199+ } ) ;
200+
132201 it ( "should add the default scss theme correctly" , async ( ) => {
133202 const targetFile = "/src/styles.scss" ;
134203 tree . create ( targetFile , "" ) ;
0 commit comments