2016-11-29 21:29:29 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-11-29 21:29:29 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-11-29 21:29:29 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
|
2017-04-21 15:16:17 +00:00
|
|
|
#import <RCTTest/RCTTestRunner.h>
|
2016-12-01 15:03:48 +00:00
|
|
|
#import <React/RCTBridge.h>
|
|
|
|
#import <React/RCTDevMenu.h>
|
2016-11-29 21:29:29 +00:00
|
|
|
|
|
|
|
typedef void(^RCTDevMenuAlertActionHandler)(UIAlertAction *action);
|
|
|
|
|
|
|
|
@interface RCTDevMenu ()
|
|
|
|
|
|
|
|
- (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *)item;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface RCTDevMenuTests : XCTestCase
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation RCTDevMenuTests
|
|
|
|
{
|
|
|
|
RCTBridge *_bridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setUp
|
|
|
|
{
|
|
|
|
[super setUp];
|
|
|
|
|
|
|
|
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
2017-05-06 03:50:47 +00:00
|
|
|
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"RNTesterUnitTestsBundle" withExtension:@"js"]
|
2016-11-29 21:29:29 +00:00
|
|
|
moduleProvider:nil
|
|
|
|
launchOptions:nil];
|
2017-04-19 23:53:44 +00:00
|
|
|
|
2017-04-21 15:16:17 +00:00
|
|
|
RCT_RUN_RUNLOOP_WHILE(_bridge.isLoading);
|
2016-11-29 21:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)testShowCreatingActionSheet
|
|
|
|
{
|
|
|
|
XCTAssertFalse([_bridge.devMenu isActionSheetShown]);
|
|
|
|
[_bridge.devMenu show];
|
|
|
|
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)testClosingActionSheetAfterAction
|
|
|
|
{
|
|
|
|
for (RCTDevMenuItem *item in _bridge.devMenu.presentedItems) {
|
|
|
|
RCTDevMenuAlertActionHandler handler = [_bridge.devMenu alertActionHandlerForDevItem:item];
|
|
|
|
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
|
|
|
|
|
|
|
|
handler(nil);
|
|
|
|
XCTAssertFalse([_bridge.devMenu isActionSheetShown]);
|
|
|
|
|
|
|
|
[_bridge.devMenu show];
|
|
|
|
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|