@@ -116,7 +116,7 @@ describe('Platform Service Tests', () => {
116116
117117 try {
118118 platformService . addPlatforms ( [ "android" ] ) . wait ( ) ;
119- } catch ( err ) {
119+ } catch ( err ) {
120120 assert . equal ( errorMessage , err . message ) ;
121121 }
122122 } ) ;
@@ -135,7 +135,7 @@ describe('Platform Service Tests', () => {
135135
136136 try {
137137 platformService . addPlatforms ( [ "ios" ] ) . wait ( ) ;
138- } catch ( err ) {
138+ } catch ( err ) {
139139 assert . equal ( errorMessage , err . message ) ;
140140 }
141141 } ) ;
@@ -154,7 +154,7 @@ describe('Platform Service Tests', () => {
154154
155155 try {
156156 platformService . addPlatforms ( [ "android" ] ) . wait ( ) ;
157- } catch ( err ) {
157+ } catch ( err ) {
158158 assert . equal ( errorMessage , err . message ) ;
159159 }
160160 } ) ;
@@ -196,6 +196,7 @@ describe('Platform Service Tests', () => {
196196
197197 describe ( "prepare platform unit tests" , ( ) => {
198198 let fs : IFileSystem ;
199+
199200 beforeEach ( ( ) => {
200201 testInjector = createTestInjector ( ) ;
201202 testInjector . register ( "fs" , fsLib . FileSystem ) ;
@@ -208,6 +209,9 @@ describe('Platform Service Tests', () => {
208209 let appFolderPath = path . join ( tempFolder , "app" ) ;
209210 fs . createDirectory ( appFolderPath ) . wait ( ) ;
210211
212+ let testsFolderPath = path . join ( appFolderPath , "tests" ) ;
213+ fs . createDirectory ( testsFolderPath ) . wait ( ) ;
214+
211215 let app1FolderPath = path . join ( tempFolder , "app1" ) ;
212216 fs . createDirectory ( app1FolderPath ) . wait ( ) ;
213217
@@ -217,7 +221,7 @@ describe('Platform Service Tests', () => {
217221 return { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } ;
218222 }
219223
220- it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
224+ function testPreparePlatform ( platformToTest : string , release ?: boolean ) {
221225 let { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } = prepareDirStructure ( ) ;
222226
223227 // Add platform specific files to app and app1 folders
@@ -240,7 +244,7 @@ describe('Platform Service Tests', () => {
240244 return {
241245 appDestinationDirectoryPath : appDestFolderPath ,
242246 appResourcesDestinationDirectoryPath : appResourcesFolderPath ,
243- normalizedPlatformName : "iOS" ,
247+ normalizedPlatformName : platformToTest ,
244248 platformProjectService : {
245249 prepareProject : ( ) => Future . fromResult ( ) ,
246250 validate : ( ) => Future . fromResult ( ) ,
@@ -259,69 +263,43 @@ describe('Platform Service Tests', () => {
259263 projectData . projectDir = tempFolder ;
260264
261265 platformService = testInjector . resolve ( "platformService" ) ;
262- platformService . preparePlatform ( "ios" ) . wait ( ) ;
266+ let options : IOptions = testInjector . resolve ( "options" ) ;
267+ options . release = release ;
268+ platformService . preparePlatform ( platformToTest ) . wait ( ) ;
269+
270+ let test1FileName = platformToTest . toLowerCase ( ) === "ios" ? "test1.js" : "test2.js" ;
271+ let test2FileName = platformToTest . toLowerCase ( ) === "ios" ? "test2.js" : "test1.js" ;
263272
264273 // Asserts that the files in app folder are process as platform specific
265- assert . isTrue ( fs . exists ( path . join ( appDestFolderPath , "app" , "test1.js" ) ) . wait ( ) ) ;
274+ assert . isTrue ( fs . exists ( path . join ( appDestFolderPath , "app" , test1FileName ) ) . wait ( ) ) ;
266275 assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test1-js" ) ) . wait ( ) ) ;
267- assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test2.js" ) ) . wait ( ) ) ;
276+
277+ assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , test2FileName ) ) . wait ( ) ) ;
268278 assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test2-js" ) ) . wait ( ) ) ;
269279
270280 // Asserts that the files in app1 folder aren't process as platform specific
271- assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) ) ;
272- } ) ;
273- it ( "should process only files in app folder when preparing for Android platform" , ( ) => {
274- let { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } = prepareDirStructure ( ) ;
281+ assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) , "Asserts that the files in app1 folder aren't process as platform specific" ) ;
275282
276- // Add platform specific files to app and app1 folders
277- let platformSpecificFiles = [
278- "test1.ios.js" , "test1-ios-js" , "test2.android.js" , "test2-android-js"
279- ] ;
280-
281- let destinationDirectories = [ appFolderPath , app1FolderPath ] ;
282-
283- _ . each ( destinationDirectories , directoryPath => {
284- _ . each ( platformSpecificFiles , filePath => {
285- let fileFullPath = path . join ( directoryPath , filePath ) ;
286- fs . writeFile ( fileFullPath , "testData" ) . wait ( ) ;
287- } ) ;
288- } ) ;
289-
290- let platformsData = testInjector . resolve ( "platformsData" ) ;
291- platformsData . platformsNames = [ "ios" , "android" ] ;
292- platformsData . getPlatformData = ( platform : string ) => {
293- return {
294- appDestinationDirectoryPath : appDestFolderPath ,
295- appResourcesDestinationDirectoryPath : appResourcesFolderPath ,
296- normalizedPlatformName : "Android" ,
297- platformProjectService : {
298- prepareProject : ( ) => Future . fromResult ( ) ,
299- validate : ( ) => Future . fromResult ( ) ,
300- createProject : ( projectRoot : string , frameworkDir : string ) => Future . fromResult ( ) ,
301- interpolateData : ( projectRoot : string ) => Future . fromResult ( ) ,
302- afterCreateProject : ( projectRoot : string ) => Future . fromResult ( ) ,
303- getAppResourcesDestinationDirectoryPath : ( ) => Future . fromResult ( "" ) ,
304- processConfigurationFilesFromAppResources : ( ) => Future . fromResult ( ) ,
305- ensureConfigurationFileInAppResources : ( ) => Future . fromResult ( ) ,
306- interpolateConfigurationFile : ( ) => Future . fromResult ( )
307- }
308- } ;
309- } ;
310-
311- let projectData = testInjector . resolve ( "projectData" ) ;
312- projectData . projectDir = tempFolder ;
283+ if ( release ) {
284+ // Asserts that the files in tests folder aren't copied
285+ assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "tests" ) ) . wait ( ) , "Asserts that the files in tests folder aren't copied" ) ;
286+ }
287+ }
313288
314- platformService = testInjector . resolve ( "platformService" ) ;
315- platformService . preparePlatform ( "android" ) . wait ( ) ;
289+ it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
290+ testPreparePlatform ( "iOS" ) ;
291+ } ) ;
316292
317- // Asserts that the files in app folder are process as platform specific
318- assert . isTrue ( fs . exists ( path . join ( appDestFolderPath , "app" , "test2.js" ) ) . wait ( ) ) ;
319- assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test2-js" ) ) . wait ( ) ) ;
320- assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test1.js" ) ) . wait ( ) ) ;
321- assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test1-js" ) ) . wait ( ) ) ;
293+ it ( "should process only files in app folder when preparing for Android platform" , ( ) => {
294+ testPreparePlatform ( "Android" ) ;
295+ } ) ;
296+
297+ it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
298+ testPreparePlatform ( "iOS" , true ) ;
299+ } ) ;
322300
323- // Asserts that the files in app1 folder aren't process as platform specific
324- assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app1" ) ) . wait ( ) ) ;
301+ it ( "should process only files in app folder when preparing for Android platform" , ( ) => {
302+ testPreparePlatform ( "Android" , true ) ;
325303 } ) ;
326304
327305 it ( "invalid xml is caught" , ( ) => {
0 commit comments