react-native-navigation的迁移库

RNNTabBarPresenterTest.m 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 bindedViewController;
  10. @end
  11. @implementation RNNTabBarPresenterTest
  12. - (void)setUp {
  13. [super setUp];
  14. self.uut = [[RNNTabBarPresenter alloc] init];
  15. self.bindedViewController = [OCMockObject partialMockForObject:[RNNTabBarController new]];
  16. [self.uut bindViewController:self.bindedViewController];
  17. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  18. }
  19. - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
  20. RNNNavigationOptions* emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  21. [[self.bindedViewController expect] rnn_setTabBarTestID:nil];
  22. [[self.bindedViewController expect] rnn_setTabBarBackgroundColor:nil];
  23. [[self.bindedViewController expect] rnn_setTabBarTranslucent:NO];
  24. [[self.bindedViewController expect] rnn_setTabBarHideShadow:NO];
  25. [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleDefault];
  26. [[self.bindedViewController expect] rnn_setTabBarVisible:YES];
  27. [self.uut applyOptions:emptyOptions];
  28. [self.bindedViewController 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.bindedViewController expect] rnn_setTabBarTestID:@"testID"];
  39. [[self.bindedViewController expect] rnn_setTabBarBackgroundColor:[UIColor redColor]];
  40. [[self.bindedViewController expect] rnn_setTabBarTranslucent:NO];
  41. [[self.bindedViewController expect] rnn_setTabBarHideShadow:YES];
  42. [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleBlack];
  43. [[self.bindedViewController expect] rnn_setTabBarVisible:NO];
  44. [self.uut applyOptions:initialOptions];
  45. [self.bindedViewController verify];
  46. }
  47. - (void)testApplyOptions_shouldApplyOptionsOnSetViewControllers {
  48. RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  49. initialOptions.bottomTabs.currentTabIndex = [[IntNumber alloc] initWithValue:@(1)];
  50. [[self.bindedViewController expect] rnn_setCurrentTabIndex:1];
  51. [self.uut applyOptionsOnSetViewControllers:initialOptions];
  52. [self.bindedViewController verify];
  53. }
  54. @end