@@ -181,7 +181,8 @@ describe('Platform Service Tests', () => {
181181 testInjector . register ( "fs" , fsLib . FileSystem ) ;
182182 fs = testInjector . resolve ( "fs" ) ;
183183 } ) ;
184- it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
184+
185+ function prepareDirStructure ( ) {
185186 let tempFolder = temp . mkdirSync ( "prepare platform" ) ;
186187
187188 let appFolderPath = path . join ( tempFolder , "app" ) ;
@@ -193,6 +194,12 @@ describe('Platform Service Tests', () => {
193194 let appDestFolderPath = path . join ( tempFolder , "appDest" ) ;
194195 let appResourcesFolderPath = path . join ( appDestFolderPath , "App_Resources" ) ;
195196
197+ return { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } ;
198+ }
199+
200+ it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
201+ let { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } = prepareDirStructure ( ) ;
202+
196203 // Add platform specific files to app and app1 folders
197204 let platformSpecificFiles = [
198205 "test1.ios.js" , "test1-ios-js" , "test2.android.js" , "test2-android-js"
@@ -242,16 +249,7 @@ describe('Platform Service Tests', () => {
242249 assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) ) ;
243250 } ) ;
244251 it ( "should process only files in app folder when preparing for Android platform" , ( ) => {
245- let tempFolder = temp . mkdirSync ( "prepare platform" ) ;
246-
247- let appFolderPath = path . join ( tempFolder , "app" ) ;
248- fs . createDirectory ( appFolderPath ) . wait ( ) ;
249-
250- let app1FolderPath = path . join ( tempFolder , "app1" ) ;
251- fs . createDirectory ( app1FolderPath ) . wait ( ) ;
252-
253- let appDestFolderPath = path . join ( tempFolder , "appDest" ) ;
254- let appResourcesFolderPath = path . join ( appDestFolderPath , "App_Resources" ) ;
252+ let { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } = prepareDirStructure ( ) ;
255253
256254 // Add platform specific files to app and app1 folders
257255 let platformSpecificFiles = [
@@ -301,5 +299,42 @@ describe('Platform Service Tests', () => {
301299 // Asserts that the files in app1 folder aren't process as platform specific
302300 assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) ) ;
303301 } ) ;
302+
303+ it ( "invalid xml is caught" , ( ) => {
304+ require ( "colors" ) ;
305+ let { tempFolder, appFolderPath, appDestFolderPath, appResourcesFolderPath } = prepareDirStructure ( ) ;
306+
307+ // generate invalid xml
308+ let fileFullPath = path . join ( appFolderPath , "file.xml" ) ;
309+ fs . writeFile ( fileFullPath , "<xml><unclosedTag></xml>" ) . wait ( ) ;
310+
311+ let platformsData = testInjector . resolve ( "platformsData" ) ;
312+ platformsData . platformsNames = [ "android" ] ;
313+ platformsData . getPlatformData = ( platform : string ) => {
314+ return {
315+ appDestinationDirectoryPath : appDestFolderPath ,
316+ appResourcesDestinationDirectoryPath : appResourcesFolderPath ,
317+ normalizedPlatformName : "Android" ,
318+ platformProjectService : {
319+ prepareProject : ( ) => Future . fromResult ( ) ,
320+ validate : ( ) => Future . fromResult ( ) ,
321+ createProject : ( projectRoot : string , frameworkDir : string ) => Future . fromResult ( ) ,
322+ interpolateData : ( projectRoot : string ) => Future . fromResult ( ) ,
323+ afterCreateProject : ( projectRoot : string ) => Future . fromResult ( ) ,
324+ getAppResourcesDestinationDirectoryPath : ( ) => Future . fromResult ( "" ) ,
325+ processConfigurationFilesFromAppResources : ( ) => Future . fromResult ( )
326+ }
327+ } ;
328+ } ;
329+
330+ let projectData = testInjector . resolve ( "projectData" ) ;
331+ projectData . projectDir = tempFolder ;
332+
333+ platformService = testInjector . resolve ( "platformService" ) ;
334+ let result = platformService . preparePlatform ( "android" ) . wait ( ) ;
335+
336+ // Asserts that prepare has caught invalid xml
337+ assert . isFalse ( result ) ;
338+ } ) ;
304339 } ) ;
305340} ) ;
0 commit comments