Skip to content

Commit 06956e8

Browse files
fkgozalifacebook-github-bot
authored andcommitted
expose IS_TESTING for Platform module
Summary: Introduced IS_TESTING flag on Platform module for android as well. This is useful for testing environment. Reviewed By: mmmulani Differential Revision: D4429662 fbshipit-source-id: 33711d7fb5666f0bac8aee444b71261f7f12770f
1 parent dd8231a commit 06956e8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Libraries/Utilities/Platform.android.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const Platform = {
1818
const AndroidConstants = require('NativeModules').AndroidConstants;
1919
return AndroidConstants && AndroidConstants.Version;
2020
},
21+
get isTesting(): boolean {
22+
const constants = require('NativeModules').AndroidConstants;
23+
return constants && constants.isTesting;
24+
},
2125
select: (obj: Object) => obj.android,
2226
};
2327

ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
@ReactModule(name = "AndroidConstants")
2626
public class AndroidInfoModule extends BaseJavaModule {
2727

28+
private static final String IS_TESTING = "IS_TESTING";
29+
2830
@Override
2931
public String getName() {
3032
return "AndroidConstants";
@@ -35,6 +37,7 @@ public String getName() {
3537
HashMap<String, Object> constants = new HashMap<>();
3638
constants.put("Version", Build.VERSION.SDK_INT);
3739
constants.put("ServerHost", AndroidInfoHelpers.getServerHost());
40+
constants.put("isTesting", "true".equals(System.getProperty(IS_TESTING)));
3841
return constants;
3942
}
4043
}

0 commit comments

Comments
 (0)