@@ -116,7 +116,7 @@ describe('Platform Service Tests', () => {
116
116
117
117
try {
118
118
platformService . addPlatforms ( [ "android" ] ) . wait ( ) ;
119
- } catch ( err ) {
119
+ } catch ( err ) {
120
120
assert . equal ( errorMessage , err . message ) ;
121
121
}
122
122
} ) ;
@@ -135,7 +135,7 @@ describe('Platform Service Tests', () => {
135
135
136
136
try {
137
137
platformService . addPlatforms ( [ "ios" ] ) . wait ( ) ;
138
- } catch ( err ) {
138
+ } catch ( err ) {
139
139
assert . equal ( errorMessage , err . message ) ;
140
140
}
141
141
} ) ;
@@ -154,7 +154,7 @@ describe('Platform Service Tests', () => {
154
154
155
155
try {
156
156
platformService . addPlatforms ( [ "android" ] ) . wait ( ) ;
157
- } catch ( err ) {
157
+ } catch ( err ) {
158
158
assert . equal ( errorMessage , err . message ) ;
159
159
}
160
160
} ) ;
@@ -196,6 +196,7 @@ describe('Platform Service Tests', () => {
196
196
197
197
describe ( "prepare platform unit tests" , ( ) => {
198
198
let fs : IFileSystem ;
199
+
199
200
beforeEach ( ( ) => {
200
201
testInjector = createTestInjector ( ) ;
201
202
testInjector . register ( "fs" , fsLib . FileSystem ) ;
@@ -208,6 +209,9 @@ describe('Platform Service Tests', () => {
208
209
let appFolderPath = path . join ( tempFolder , "app" ) ;
209
210
fs . createDirectory ( appFolderPath ) . wait ( ) ;
210
211
212
+ let testsFolderPath = path . join ( appFolderPath , "tests" ) ;
213
+ fs . createDirectory ( testsFolderPath ) . wait ( ) ;
214
+
211
215
let app1FolderPath = path . join ( tempFolder , "app1" ) ;
212
216
fs . createDirectory ( app1FolderPath ) . wait ( ) ;
213
217
@@ -217,7 +221,7 @@ describe('Platform Service Tests', () => {
217
221
return { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } ;
218
222
}
219
223
220
- it ( "should process only files in app folder when preparing for iOS platform" , ( ) => {
224
+ function testPreparePlatform ( platformToTest : string , release ?: boolean ) {
221
225
let { tempFolder, appFolderPath, app1FolderPath, appDestFolderPath, appResourcesFolderPath } = prepareDirStructure ( ) ;
222
226
223
227
// Add platform specific files to app and app1 folders
@@ -240,7 +244,7 @@ describe('Platform Service Tests', () => {
240
244
return {
241
245
appDestinationDirectoryPath : appDestFolderPath ,
242
246
appResourcesDestinationDirectoryPath : appResourcesFolderPath ,
243
- normalizedPlatformName : "iOS" ,
247
+ normalizedPlatformName : platformToTest ,
244
248
platformProjectService : {
245
249
prepareProject : ( ) => Future . fromResult ( ) ,
246
250
validate : ( ) => Future . fromResult ( ) ,
@@ -259,69 +263,43 @@ describe('Platform Service Tests', () => {
259
263
projectData . projectDir = tempFolder ;
260
264
261
265
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" ;
263
272
264
273
// 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 ( ) ) ;
266
275
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 ( ) ) ;
268
278
assert . isFalse ( fs . exists ( path . join ( appDestFolderPath , "app" , "test2-js" ) ) . wait ( ) ) ;
269
279
270
280
// 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" ) ;
275
282
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
+ }
313
288
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
+ } ) ;
316
292
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
+ } ) ;
322
300
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 ) ;
325
303
} ) ;
326
304
327
305
it ( "invalid xml is caught" , ( ) => {
0 commit comments