react-native-navigation的迁移库

RNNTabBarPresenterTest.m 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNTabBarPresenter.h"
  4. #import "UITabBarController+RNNOptions.h"
  5. #import "RNNTabBarController.h"
  6. @interface RNNTabBarPresenterTest : XCTestCase
  7. @property(nonatomic, strong) RNNTabBarPresenter *uut;
  8. @property(nonatomic, strong) RNNNavigationOptions *options;
  9. @property(nonatomic, strong) id boundViewController;
  10. @end
  11. @implementation RNNTabBarPresenterTest
  12. - (void)setUp {
  13. [super setUp];
  14. self.uut = [OCMockObject partialMockForObject:[RNNTabBarPresenter new]];
  15. self.boundViewController = [OCMockObject partialMockForObject:[RNNTabBarController new]];
  16. [self.uut bindViewController:self.boundViewController];
  17. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  18. }
  19. - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
  20. RNNNavigationOptions *emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  21. [[self.boundViewController expect] rnn_setTabBarTestID:nil];
  22. [[self.boundViewController expect] rnn_setTabBarBackgroundColor:nil];
  23. [[self.boundViewController expect] rnn_setTabBarTranslucent:NO];
  24. [[self.boundViewController expect] rnn_setTabBarHideShadow:NO];
  25. [[self.boundViewController expect] rnn_setTabBarStyle:UIBarStyleDefault];
  26. [[self.boundViewController expect] rnn_setTabBarVisible:YES animated:NO];
  27. [self.uut applyOptions:emptyOptions];
  28. [self.boundViewController verify];
  29. }
  30. - (void)testApplyOptions_shouldApplyOptions {
  31. RNNNavigationOptions *initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  32. initialOptions.bottomTabs.testID = [[Text alloc] initWithValue:@"testID"];
  33. initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
  34. initialOptions.bottomTabs.translucent = [[Bool alloc] initWithValue:@(0)];
  35. initialOptions.bottomTabs.hideShadow = [[Bool alloc] initWithValue:@(1)];
  36. initialOptions.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
  37. initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
  38. [[self.boundViewController expect] rnn_setTabBarTestID:@"testID"];
  39. [[self.boundViewController expect] rnn_setTabBarBackgroundColor:[UIColor redColor]];
  40. [[self.boundViewController expect] rnn_setTabBarTranslucent:NO];
  41. [[self.boundViewController expect] rnn_setTabBarHideShadow:YES];
  42. [[self.boundViewController expect] rnn_setTabBarStyle:UIBarStyleBlack];
  43. [[self.boundViewController expect] rnn_setTabBarVisible:NO animated:NO];
  44. [self.uut applyOptions:initialOptions];
  45. [self.boundViewController verify];
  46. }
  47. - (void)testViewDidLayoutSubviews_appliesBadgeOnNextRunLoop {
  48. id uut = [self uut];
  49. [[uut expect] applyDotIndicator];
  50. [uut viewDidLayoutSubviews];
  51. [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
  52. [uut verify];
  53. }
  54. - (void)testApplyDotIndicator_callsAppliesBadgeWithEachChild {
  55. id uut = [self uut];
  56. id child1 = [UIViewController new];
  57. id child2 = [UIViewController new];
  58. [[uut expect] applyDotIndicator:child1];
  59. [[uut expect] applyDotIndicator:child2];
  60. [[self boundViewController] addChildViewController:child1];
  61. [[self boundViewController] addChildViewController:child2];
  62. [uut applyDotIndicator];
  63. [uut verify];
  64. }
  65. @end