@@ -89,7 +89,8 @@ describe("Unit - IgniteUIForAngularTemplate Base", () => {
8989 . toHaveBeenCalledWith ( path . join ( "target/path" , "src/app/app-module.ts" ) , false , { indentSize : 2 , singleQuotes : true } ) ;
9090 expect ( helpers . tsUpdateMock . addNgModuleMeta ) . toHaveBeenCalledWith (
9191 {
92- declare : [
92+ declare : [ ] ,
93+ import : [
9394 "ViewName" ,
9495 ] ,
9596 from : "./view-name/view-name" ,
@@ -189,7 +190,8 @@ describe("Unit - IgniteUIForAngularTemplate Base", () => {
189190 . toHaveBeenCalledWith ( path . join ( "target/path" , "src/app/app-module.ts" ) , false , { indentSize : 2 , singleQuotes : true } ) ;
190191 expect ( helpers . tsUpdateMock . addNgModuleMeta ) . toHaveBeenCalledWith (
191192 {
192- declare : [
193+ declare : [ ] ,
194+ import : [
193195 "ViewName" ,
194196 ] ,
195197 from : "./view-name/view-name" ,
@@ -201,6 +203,68 @@ describe("Unit - IgniteUIForAngularTemplate Base", () => {
201203 expect ( helpers . tsUpdateMock . finalize ) . toHaveBeenCalled ( ) ;
202204 } ) ;
203205
206+ it ( "should declare in NgModule when addAsNgModelDeclaration is true" , async ( ) => {
207+ const templ = new TestTemplate ( ) ;
208+ templ . addAsNgModelDeclaration = true ;
209+ templ . addAsNgModelImport = false ;
210+ const mockFS = {
211+ fileExists : ( file : string ) : boolean => {
212+ return false ;
213+ } ,
214+ readFile : ( file : string , encoding ?: BufferEncoding ) : string => {
215+ return JSON . stringify ( { key : "value" } ) ;
216+ } ,
217+ writeFile : ( file : string , text : string ) : void => { } ,
218+ } ;
219+ spyOn ( App . container , "get" ) . and . returnValue ( mockFS ) ;
220+ spyOn ( templ , "fileExists" ) . and . returnValue ( true ) ;
221+ templ . registerInProject ( "target/path" , "view name" ) ;
222+ expect ( helpers . tsUpdateMock . addNgModuleMeta ) . toHaveBeenCalledWith (
223+ {
224+ declare : [
225+ "ViewName" ,
226+ ] ,
227+ import : [ ] ,
228+ from : "./view-name/view-name" ,
229+ export : [ ]
230+ } ,
231+ jasmine . any ( Object ) ,
232+ true
233+ ) ;
234+ } ) ;
235+
236+ it ( "should both declare and import in NgModule when both flags are true" , async ( ) => {
237+ const templ = new TestTemplate ( ) ;
238+ templ . addAsNgModelDeclaration = true ;
239+ templ . addAsNgModelImport = true ;
240+ const mockFS = {
241+ fileExists : ( file : string ) : boolean => {
242+ return false ;
243+ } ,
244+ readFile : ( file : string , encoding ?: BufferEncoding ) : string => {
245+ return JSON . stringify ( { key : "value" } ) ;
246+ } ,
247+ writeFile : ( file : string , text : string ) : void => { } ,
248+ } ;
249+ spyOn ( App . container , "get" ) . and . returnValue ( mockFS ) ;
250+ spyOn ( templ , "fileExists" ) . and . returnValue ( true ) ;
251+ templ . registerInProject ( "target/path" , "view name" ) ;
252+ expect ( helpers . tsUpdateMock . addNgModuleMeta ) . toHaveBeenCalledWith (
253+ {
254+ declare : [
255+ "ViewName" ,
256+ ] ,
257+ import : [
258+ "ViewName" ,
259+ ] ,
260+ from : "./view-name/view-name" ,
261+ export : [ ]
262+ } ,
263+ jasmine . any ( Object ) ,
264+ true
265+ ) ;
266+ } ) ;
267+
204268 it ( "generateConfig merges variables passed under extraConfig" , async ( ) => {
205269 const expected = {
206270 camelCaseName : "test" ,
0 commit comments