2016-11-29 21:29:29 +00:00
|
|
|
/**
|
|
|
|
* The examples provided by Facebook are for non-commercial testing and
|
|
|
|
* evaluation purposes only.
|
|
|
|
*
|
|
|
|
* Facebook reserves all rights not expressly granted.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
|
2017-04-21 15:16:17 +00:00
|
|
|
#import <RCTTest/RCTTestRunner.h>
|
2017-04-19 23:53:44 +00:00
|
|
|
#import <React/RCTBridge+JavaScriptCore.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-02-25 11:12:41 +00:00
|
|
|
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"UIExplorerUnitTestsBundle" 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
|