react-native-navigation的迁移库

RNNBottomTabPresenterTest.m 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #import <XCTest/XCTest.h>
  2. #import "RNNBottomTabPresenter.h"
  3. #import <OCMock/OCMock.h>
  4. #import "UIViewController+RNNOptions.h"
  5. @interface RNNBottomTabPresenterTest : XCTestCase
  6. @property (nonatomic, strong) RNNBottomTabPresenter *uut;
  7. @property (nonatomic, strong) RNNNavigationOptions *options;
  8. @property (nonatomic, strong) id bindedViewController;
  9. @end
  10. @implementation RNNBottomTabPresenterTest
  11. - (void)setUp {
  12. [super setUp];
  13. self.uut = [[RNNBottomTabPresenter 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_shouldSetTabBarItemBadgeWithDefault {
  19. [[self.bindedViewController expect] rnn_setTabBarItemBadge:nil];
  20. [self.uut applyOptions:self.options];
  21. [self.bindedViewController verify];
  22. }
  23. - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
  24. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  25. [[self.bindedViewController expect] rnn_setTabBarItemBadge:@"badge"];
  26. [self.uut applyOptions:self.options];
  27. [self.bindedViewController verify];
  28. }
  29. - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
  30. self.bindedViewController = [OCMockObject partialMockForObject:[UITabBarController new]];
  31. [self.uut bindViewController:self.bindedViewController];
  32. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  33. [[self.bindedViewController reject] rnn_setTabBarItemBadge:@"badge"];
  34. [self.uut applyOptions:self.options];
  35. [self.bindedViewController verify];
  36. }
  37. //- (void)test_tabBarTextFontFamily_validFont {
  38. // UIViewController* viewController = [UIViewController new];
  39. //
  40. // NSString* inputFont = @"HelveticaNeue";
  41. // UIFont* expectedFont = [UIFont fontWithName:inputFont size:10];
  42. //
  43. // self.uut.fontFamily = inputFont;
  44. // self.uut.text = @"Tab 1";
  45. //
  46. // [self.uut rnn_set];
  47. //
  48. // NSDictionary* attributes = [viewController.tabBarItem titleTextAttributesForState:UIControlStateNormal];
  49. // XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
  50. //}
  51. //- (void)test_tabBarTextFontSize_withoutTextFontFamily_withoutTextColor {
  52. // UIViewController* viewController = [UIViewController new];
  53. //
  54. // UIFont* expectedFont = [UIFont systemFontOfSize:15];
  55. //
  56. // self.uut.fontSize = @(15);
  57. // self.uut.text = @"Tab 1";
  58. //
  59. // [self.uut applyOn:viewController];
  60. //
  61. // NSDictionary* attributes = [viewController.tabBarItem titleTextAttributesForState:UIControlStateNormal];
  62. // XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
  63. //}
  64. //
  65. //- (void)test_tabBarTextFontSize_withoutTextFontFamily {
  66. // UIViewController* viewController = [UIViewController new];
  67. //
  68. // UIFont* expectedFont = [UIFont systemFontOfSize:15];
  69. //
  70. // self.uut.fontSize = @(15);
  71. // self.uut.text = @"Tab 1";
  72. //
  73. // [self.uut applyOn:viewController];
  74. //
  75. // NSDictionary* attributes = [viewController.tabBarItem titleTextAttributesForState:UIControlStateNormal];
  76. // XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
  77. //}
  78. //
  79. //- (void)test_tabBarTextFontSize_withTextFontFamily_withTextColor {
  80. // UIViewController* viewController = [UIViewController new];
  81. //
  82. // NSString* inputFont = @"HelveticaNeue";
  83. // UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
  84. //
  85. // self.uut.fontSize = @(15);
  86. // self.uut.text = @"Tab 1";
  87. // self.uut.fontFamily = inputFont;
  88. // self.uut.textColor = @(4279979127);
  89. // [self.uut applyOn:viewController];
  90. //
  91. // NSDictionary* attributes = [viewController.tabBarItem titleTextAttributesForState:UIControlStateNormal];
  92. // UIColor* color = attributes[NSForegroundColorAttributeName];
  93. // UIColor* expectedColor = [RCTConvert UIColor:@(4279979127)];
  94. //
  95. // XCTAssertTrue([color isEqual:expectedColor]);
  96. // XCTAssertTrue([attributes[@"NSFont"] isEqual:expectedFont]);
  97. //}
  98. @end