@@ -181,7 +181,8 @@ describe('Platform Service Tests', () => {
181
181
testInjector . register ( "fs" , fsLib . FileSystem ) ;
182
182
fs = testInjector . resolve ( "fs" ) ;
183
183
} ) ;
184
- it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
184
+
185
+ function prepareDirStructure ( ) {
185
186
let tempFolder = temp . mkdirSync ( "prepare platform" ) ;
186
187
187
188
let appFolderPath = path . join ( tempFolder , "app" ) ;
@@ -193,6 +194,12 @@ describe('Platform Service Tests', () => {
193
194
let appDestFolderPath = path . join ( tempFolder , "appDest" ) ;
194
195
let appResourcesFolderPath = path . join ( appDestFolderPath , "App_Resources" ) ;
195
196
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
+
196
203
// Add platform specific files to app and app1 folders
197
204
let platformSpecificFiles = [
198
205
"test1.ios.js" , "test1-ios-js" , "test2.android.js" , "test2-android-js"
@@ -242,16 +249,7 @@ describe('Platform Service Tests', () => {
242
249
assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) ) ;
243
250
} ) ;
244
251
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 ( ) ;
255
253
256
254
// Add platform specific files to app and app1 folders
257
255
let platformSpecificFiles = [
@@ -301,5 +299,42 @@ describe('Platform Service Tests', () => {
301
299
// Asserts that the files in app1 folder aren't process as platform specific
302
300
assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) ) ;
303
301
} ) ;
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
+ } ) ;
304
339
} ) ;
305
340
} ) ;
0 commit comments