Merge RCTPlatform.isTesting and RCTRunningInTestEnvironment
Reviewed By: fkgozali Differential Revision: D4802834 fbshipit-source-id: 76bb98877f2fc427c01806b192d8dc71489a1c4a
This commit is contained in:
parent
5af30382d5
commit
f6754348be
|
@ -30,11 +30,6 @@ static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL isTestingEnvironment(void) {
|
||||
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
|
||||
return [environment[@"IS_TESTING"] boolValue];
|
||||
}
|
||||
|
||||
RCT_EXPORT_MODULE(PlatformConstants)
|
||||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
|
@ -45,7 +40,7 @@ RCT_EXPORT_MODULE(PlatformConstants)
|
|||
@"osVersion": [device systemVersion],
|
||||
@"systemName": [device systemName],
|
||||
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
|
||||
@"isTesting": @(isTestingEnvironment()),
|
||||
@"isTesting": @(RCTRunningInTestEnvironment()),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -9,17 +9,16 @@
|
|||
|
||||
#import "RCTUtils.h"
|
||||
|
||||
#import <dlfcn.h>
|
||||
#import <mach/mach_time.h>
|
||||
#import <objc/message.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <zlib.h>
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
|
||||
#import <zlib.h>
|
||||
#import <dlfcn.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTLog.h"
|
||||
|
||||
|
@ -445,7 +444,9 @@ BOOL RCTRunningInTestEnvironment(void)
|
|||
static BOOL isTestEnvironment = NO;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
isTestEnvironment = objc_lookUpClass("SenTestCase") || objc_lookUpClass("XCTest");
|
||||
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
|
||||
isTestEnvironment = objc_lookUpClass("SenTestCase") || objc_lookUpClass("XCTest") ||
|
||||
[environment[@"IS_TESTING"] boolValue];
|
||||
});
|
||||
return isTestEnvironment;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue