From f6754348be617e9e6d79865e24894af0bd027ee0 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 30 Mar 2017 09:53:51 -0700 Subject: [PATCH] Merge RCTPlatform.isTesting and RCTRunningInTestEnvironment Reviewed By: fkgozali Differential Revision: D4802834 fbshipit-source-id: 76bb98877f2fc427c01806b192d8dc71489a1c4a --- React/Base/RCTPlatform.m | 7 +------ React/Base/RCTUtils.m | 9 +++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/React/Base/RCTPlatform.m b/React/Base/RCTPlatform.m index f082a215e..122d4231b 100644 --- a/React/Base/RCTPlatform.m +++ b/React/Base/RCTPlatform.m @@ -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 *)constantsToExport @@ -45,7 +40,7 @@ RCT_EXPORT_MODULE(PlatformConstants) @"osVersion": [device systemVersion], @"systemName": [device systemName], @"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]), - @"isTesting": @(isTestingEnvironment()), + @"isTesting": @(RCTRunningInTestEnvironment()), }; } diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 4cf287359..4e2ed4623 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -9,17 +9,16 @@ #import "RCTUtils.h" +#import #import #import #import +#import #import #import -#import -#import - #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; }