diff --git a/lib/ios/RNNCommandsHandler.m b/lib/ios/RNNCommandsHandler.m index 4a88f5464bd..3f9a376bbd6 100644 --- a/lib/ios/RNNCommandsHandler.m +++ b/lib/ios/RNNCommandsHandler.m @@ -250,7 +250,7 @@ - (void)showModal:(NSDictionary*)layout commandId:(NSString *)commandId completi UIViewController *newVc = [_controllerFactory createLayout:layout]; [newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{ - [_modalManager showModal:newVc animated:[newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) { + [_modalManager showModal:newVc animated:[newVc.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) { [_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}]; completion(newVc.layoutInfo.componentId); }]; diff --git a/lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m b/lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m index e9a21a5f8d8..957bf15aaf8 100644 --- a/lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m +++ b/lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m @@ -42,6 +42,7 @@ @implementation MockUINavigationController @interface RNNCommandsHandlerTest : XCTestCase @property (nonatomic, strong) RNNCommandsHandler* uut; +@property (nonatomic, strong) id modalManager; @property (nonatomic, strong) RNNRootViewController* vc1; @property (nonatomic, strong) RNNRootViewController* vc2; @property (nonatomic, strong) RNNRootViewController* vc3; @@ -61,8 +62,9 @@ - (void)setUp { self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]]; self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]]; self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]]; + self.modalManager = [OCMockObject partialMockForObject:[RNNModalManager new]]; self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil]]; - self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:_mainWindow]; + self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:self.modalManager overlayManager:self.overlayManager mainWindow:_mainWindow]; self.vc1 = [RNNRootViewController new]; self.vc2 = [RNNRootViewController new]; self.vc3 = [RNNRootViewController new]; @@ -313,4 +315,20 @@ - (void)testSetRoot_waitForRenderFalse { [mockedVC verify]; } +- (void)testShowModal_shouldShowAnimated { + [self.uut setReadyToReceiveCommands:true]; + self.vc1.options = [[RNNNavigationOptions alloc] initEmptyOptions]; + self.vc1.options.animations.showModal.enable = [[Bool alloc] initWithBOOL:YES]; + + id mockedVC = [OCMockObject partialMockForObject:self.vc1]; + OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC); + + [[self.modalManager expect] showModal:mockedVC animated:YES hasCustomAnimation:NO completion:[OCMArg any]]; + [self.uut showModal:@{} commandId:@"showModal" completion:^(NSString *componentId) { + + }]; + [self.modalManager verify]; +} + + @end