react-native-navigation的迁移库

RNNViewControllerPresenterTest.m 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNViewControllerPresenter.h"
  4. #import "UIViewController+RNNOptions.h"
  5. @interface RNNViewControllerPresenterTest : XCTestCase
  6. @property (nonatomic, strong) RNNViewControllerPresenter *uut;
  7. @property (nonatomic, strong) RNNNavigationOptions *options;
  8. @property (nonatomic, strong) UIViewController *bindedViewController;
  9. @end
  10. @implementation RNNViewControllerPresenterTest
  11. - (void)setUp {
  12. [super setUp];
  13. self.uut = [[RNNViewControllerPresenter alloc] init];
  14. self.bindedViewController = [OCMockObject partialMockForObject:[UIViewController new]];
  15. [self.uut bindViewController:self.bindedViewController];
  16. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  17. }
  18. - (void)testApplyOptions_backgroundImageDefaultNil {
  19. [self.uut applyOptions:self.options];
  20. XCTAssertNil(((UIImageView *)self.bindedViewController.view.subviews[0]).image);
  21. }
  22. - (void)testApplyOptions_topBarPrefersLargeTitleDefaultFalse {
  23. [self.uut applyOptions:self.options];
  24. XCTAssertTrue(self.bindedViewController.navigationItem.largeTitleDisplayMode == UINavigationItemLargeTitleDisplayModeNever);
  25. }
  26. - (void)testApplyOptions_layoutBackgroundColorDefaultWhiteColor {
  27. [self.uut applyOptions:self.options];
  28. XCTAssertNil(self.bindedViewController.view.backgroundColor);
  29. }
  30. - (void)testApplyOptions_statusBarBlurDefaultFalse {
  31. [self.uut applyOptions:self.options];
  32. XCTAssertNil([self.bindedViewController.view viewWithTag:BLUR_STATUS_TAG]);
  33. }
  34. - (void)testApplyOptions_statusBarStyleDefaultStyle {
  35. [self.uut applyOptions:self.options];
  36. XCTAssertTrue([self.bindedViewController preferredStatusBarStyle] == UIStatusBarStyleDefault);
  37. }
  38. - (void)testApplyOptions_backButtonVisibleDefaultTrue {
  39. [self.uut applyOptions:self.options];
  40. XCTAssertFalse(self.bindedViewController.navigationItem.hidesBackButton);
  41. }
  42. - (void)testApplyOptions_drawBehindTabBarTrueWhenVisibleFalse {
  43. self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
  44. [[(id)self.bindedViewController expect] rnn_setDrawBehindTabBar:YES];
  45. [self.uut applyOptions:self.options];
  46. [(id)self.bindedViewController verify];
  47. }
  48. - (void)testApplyOptionsOnInit_shouldSetModalPresentetionStyleWithDefault {
  49. [[(id)self.bindedViewController expect] rnn_setModalPresentationStyle:UIModalPresentationFullScreen];
  50. [self.uut applyOptionsOnInit:self.options];
  51. [(id)self.bindedViewController verify];
  52. }
  53. - (void)testApplyOptionsOnInit_shouldSetModalTransitionStyleWithDefault {
  54. [[(id)self.bindedViewController expect] rnn_setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
  55. [self.uut applyOptionsOnInit:self.options];
  56. [(id)self.bindedViewController verify];
  57. }
  58. - (void)testApplyOptionsOnInit_shouldSetModalPresentetionStyleWithValue {
  59. self.options.modalPresentationStyle = [[Text alloc] initWithValue:@"overCurrentContext"];
  60. [[(id)self.bindedViewController expect] rnn_setModalPresentationStyle:UIModalPresentationOverCurrentContext];
  61. [self.uut applyOptionsOnInit:self.options];
  62. [(id)self.bindedViewController verify];
  63. }
  64. - (void)testApplyOptionsOnInit_shouldSetModalTransitionStyleWithValue {
  65. self.options.modalTransitionStyle = [[Text alloc] initWithValue:@"crossDissolve"];
  66. [[(id)self.bindedViewController expect] rnn_setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
  67. [self.uut applyOptionsOnInit:self.options];
  68. [(id)self.bindedViewController verify];
  69. }
  70. @end