@@ -24,12 +24,10 @@ const REACT_NATIVE_MOCK = {
24
24
module.exports = {
25
25
platforms: {
26
26
ios: {
27
- linkConfig: ios.linkConfig,
28
27
projectConfig: ios.projectConfig,
29
28
dependencyConfig: ios.dependencyConfig,
30
29
},
31
30
android: {
32
- linkConfig: android.linkConfig,
33
31
projectConfig: android.projectConfig,
34
32
dependencyConfig: android.dependencyConfig,
35
33
},
@@ -38,6 +36,21 @@ const REACT_NATIVE_MOCK = {
38
36
` ,
39
37
} ;
40
38
39
+ const PLATFORM_MOCK = {
40
+ 'node_modules/react-native-os/package.json' : '{}' ,
41
+ 'node_modules/react-native-os/react-native.config.js' : `
42
+ const os = require("${ iosPath } ");
43
+ module.exports = {
44
+ platforms: {
45
+ os: {
46
+ projectConfig: os.projectConfig,
47
+ dependencyConfig: os.dependencyConfig,
48
+ },
49
+ },
50
+ };
51
+ ` ,
52
+ } ;
53
+
41
54
// Removes string from all key/values within an object
42
55
const removeString = ( config , str ) =>
43
56
JSON . parse (
@@ -373,6 +386,70 @@ test('should apply build types from dependency config', async () => {
373
386
) . toMatchSnapshot ( ) ;
374
387
} ) ;
375
388
389
+ test ( 'should be able to read multiple platforms from many packages' , async ( ) => {
390
+ DIR = getTempDirectory ( 'config_test_apply_dependency_config' ) ;
391
+ writeFiles ( DIR , {
392
+ ...REACT_NATIVE_MOCK ,
393
+ ...PLATFORM_MOCK ,
394
+ 'package.json' : `{
395
+ "dependencies": {
396
+ "react-native": "0.0.1",
397
+ "react-native-os": "0.0.1"
398
+ }
399
+ }` ,
400
+ } ) ;
401
+ const { platforms} = await loadConfigAsync ( { projectRoot : DIR } ) ;
402
+ expect ( removeString ( platforms , DIR ) ) . toMatchInlineSnapshot ( `
403
+ Object {
404
+ "android": Object {},
405
+ "ios": Object {},
406
+ "os": Object {},
407
+ }
408
+ ` ) ;
409
+ } ) ;
410
+
411
+ test ( 'should be able to read only selected platform' , async ( ) => {
412
+ DIR = getTempDirectory ( 'config_test_apply_dependency_config' ) ;
413
+ writeFiles ( DIR , {
414
+ ...REACT_NATIVE_MOCK ,
415
+ ...PLATFORM_MOCK ,
416
+ 'package.json' : `{
417
+ "dependencies": {
418
+ "react-native": "0.0.1",
419
+ "react-native-os": "0.0.1"
420
+ }
421
+ }` ,
422
+ } ) ;
423
+ const { platforms} = await loadConfigAsync ( {
424
+ projectRoot : DIR ,
425
+ selectedPlatform : 'os' ,
426
+ } ) ;
427
+ expect ( removeString ( platforms , DIR ) ) . toMatchInlineSnapshot ( `
428
+ Object {
429
+ "os": Object {},
430
+ }
431
+ ` ) ;
432
+ } ) ;
433
+
434
+ test ( 'should be able to read no platforms when non-existent selected' , async ( ) => {
435
+ DIR = getTempDirectory ( 'config_test_apply_dependency_config' ) ;
436
+ writeFiles ( DIR , {
437
+ ...REACT_NATIVE_MOCK ,
438
+ ...PLATFORM_MOCK ,
439
+ 'package.json' : `{
440
+ "dependencies": {
441
+ "react-native": "0.0.1",
442
+ "react-native-os": "0.0.1"
443
+ }
444
+ }` ,
445
+ } ) ;
446
+ const { platforms} = await loadConfigAsync ( {
447
+ projectRoot : DIR ,
448
+ selectedPlatform : 'macos' ,
449
+ } ) ;
450
+ expect ( removeString ( platforms , DIR ) ) . toMatchInlineSnapshot ( `Object {}` ) ;
451
+ } ) ;
452
+
376
453
test ( 'supports dependencies from user configuration with custom build type' , async ( ) => {
377
454
DIR = getTempDirectory ( 'config_test_apply_custom_build_config' ) ;
378
455
writeFiles ( DIR , {
0 commit comments