@@ -340,7 +340,7 @@ describe('Platform Service Tests', () => {
340
340
} ) ;
341
341
342
342
function prepareDirStructure ( ) {
343
- let tempFolder = temp . mkdirSync ( "prepare platform " ) ;
343
+ let tempFolder = temp . mkdirSync ( "prepare_platform " ) ;
344
344
345
345
let appFolderPath = path . join ( tempFolder , "app" ) ;
346
346
fs . createDirectory ( appFolderPath ) ;
@@ -378,13 +378,13 @@ describe('Platform Service Tests', () => {
378
378
interpolateData : ( projectRoot : string ) => Promise . resolve ( ) ,
379
379
afterCreateProject : ( projectRoot : string ) : any => null ,
380
380
getAppResourcesDestinationDirectoryPath : ( projectData : IProjectData , frameworkVersion ?: string ) : string => {
381
- if ( platform === "ios" ) {
381
+ if ( platform . toLowerCase ( ) === "ios" ) {
382
382
let dirPath = path . join ( testDirData . tempFolder , projectData . projectName ,
383
383
"Resources" ) ;
384
384
fs . ensureDirectoryExists ( dirPath ) ;
385
385
return dirPath ;
386
386
} else {
387
- let dirPath = path . join ( testDirData . tempFolder , "src" , "main" , "res" ) ;
387
+ let dirPath = path . join ( testDirData . tempFolder , projectData . projectName , "src" , "main" , "res" ) ;
388
388
fs . ensureDirectoryExists ( dirPath ) ;
389
389
return dirPath ;
390
390
}
@@ -471,10 +471,21 @@ describe('Platform Service Tests', () => {
471
471
472
472
function assertFileContent ( createdItems : CreatedItems , expectedFileContent : string , fileName : string ) {
473
473
let destinationFilePath = path . join ( createdItems . testDirData . appDestFolderPath , "app" , fileName ) ;
474
+
474
475
let actual = fs . readFile ( destinationFilePath ) ;
475
476
assert . equal ( actual , expectedFileContent ) ;
476
477
}
477
478
479
+ function assertFilesExistance ( createdItems : CreatedItems , present : boolean , fileNames : string [ ] ) {
480
+ _ . each ( fileNames , ( fileName ) => assertFileExistance ( createdItems , present , fileName ) ) ;
481
+ }
482
+
483
+ function assertFileExistance ( createdItems : CreatedItems , present : boolean , fileName : string ) {
484
+ let destinationFilePath = path . join ( createdItems . testDirData . appDestFolderPath , "app" , fileName ) ;
485
+ let fileExists = fs . exists ( destinationFilePath ) ;
486
+ assert . equal ( fileExists , present ) ;
487
+ }
488
+
478
489
it ( "should process only files in app folder when preparing for iOS platform" , async ( ) => {
479
490
await testPreparePlatform ( "iOS" ) ;
480
491
} ) ;
@@ -499,18 +510,58 @@ describe('Platform Service Tests', () => {
499
510
500
511
await execPreparePlatform ( "iOS" , createdItems . testDirData ) ;
501
512
513
+ // assert the updated file have been copied to the destination
502
514
assertFileContent ( createdItems , expectedFileContent , "test1.js" ) ;
515
+
516
+ // assert the platform specific files for Android are not copied.
517
+ assertFilesExistance ( createdItems , false , [ "test1.ios.js" , "test2.android.js" , "test2.js" ] ) ;
518
+ assertFilesExistance ( createdItems , true , [ "test1.js" , "test2-android-js" , "test1-ios-js" ] ) ;
519
+ assertFileContent ( createdItems , "test-image" , "Resources/icon.png" ) ;
503
520
} ) ;
504
521
505
- it ( "should sync only changed files, without special folders (Android)" , async ( ) => {
522
+ it ( "should sync only changed files, without special folders (Android) #2697 " , async ( ) => {
506
523
let createdItems = await testPreparePlatform ( "Android" ) ;
507
524
508
525
const expectedFileContent = "updated-content-android" ;
509
526
updateFile ( createdItems . files , "test2.android.js" , expectedFileContent ) ;
510
527
511
528
await execPreparePlatform ( "Android" , createdItems . testDirData ) ;
512
529
530
+ // assert the updated file have been copied to the destination
513
531
assertFileContent ( createdItems , expectedFileContent , "test2.js" ) ;
532
+
533
+ // assert the platform specific files for iOS are not copied.
534
+ assertFilesExistance ( createdItems , false , [ "test1.android.js" , "test2.ios.js" , "test1.js" ] ) ;
535
+ assertFilesExistance ( createdItems , true , [ "test2.js" , "test2-android-js" , "test1-ios-js" ] ) ;
536
+ assertFileContent ( createdItems , "test-image" , "src/main/res/Resources/icon.png" ) ;
537
+ } ) ;
538
+
539
+ it ( "Ensure, App_Resources are not copied in the appDest and left there (iOS) #2697" , async ( ) => {
540
+ let createdItems = await testPreparePlatform ( "iOS" ) ;
541
+
542
+ const expectedFileContent = "updated-content-ios" ;
543
+ updateFile ( createdItems . files , "test1.ios.js" , expectedFileContent ) ;
544
+
545
+ await execPreparePlatform ( "iOS" , createdItems . testDirData ) ;
546
+
547
+ // assert the App_Resources are not left copied in the destination App Folder
548
+ let appResourcesPath = path . join ( createdItems . testDirData . appDestFolderPath , "app/App_Resources" ) ;
549
+ let dirExists = fs . exists ( appResourcesPath ) ;
550
+ assert . equal ( dirExists , false ) ;
551
+ } ) ;
552
+
553
+ it ( "Ensure, App_Resources are not copied in the appDest and left there (Android) #2697" , async ( ) => {
554
+ let createdItems = await testPreparePlatform ( "Android" ) ;
555
+
556
+ const expectedFileContent = "updated-content-android" ;
557
+ updateFile ( createdItems . files , "test2.android.js" , expectedFileContent ) ;
558
+
559
+ await execPreparePlatform ( "Android" , createdItems . testDirData ) ;
560
+
561
+ // assert the App_Resources are not left copied in the destination App Folder
562
+ let appResourcesPath = path . join ( createdItems . testDirData . appDestFolderPath , "app/App_Resources" ) ;
563
+ let dirExists = fs . exists ( appResourcesPath ) ;
564
+ assert . equal ( dirExists , false ) ;
514
565
} ) ;
515
566
516
567
it ( "invalid xml is caught" , async ( ) => {
0 commit comments