react-native-navigation的迁移库

RNNTabBarPresenterTest.m 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNTabBarPresenter.h"
  4. #import "UITabBarController+RNNOptions.h"
  5. @interface RNNTabBarPresenterTest : XCTestCase
  6. @property (nonatomic, strong) RNNTabBarPresenter *uut;
  7. @property (nonatomic, strong) RNNNavigationOptions *options;
  8. @property (nonatomic, strong) id bindedViewController;
  9. @end
  10. @implementation RNNTabBarPresenterTest
  11. - (void)setUp {
  12. [super setUp];
  13. self.uut = [[RNNTabBarPresenter alloc] init];
  14. self.bindedViewController = [OCMockObject partialMockForObject:[UITabBarController new]];
  15. [self.uut bindViewController:self.bindedViewController];
  16. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  17. }
  18. - (void)testApplyOptions_shouldSetDefaultEmptyOptions {
  19. RNNNavigationOptions* emptyOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  20. [[self.bindedViewController expect] rnn_setTabBarTestID:nil];
  21. [[self.bindedViewController expect] rnn_setTabBarBackgroundColor:nil];
  22. [[self.bindedViewController expect] rnn_setTabBarTranslucent:YES];
  23. [[self.bindedViewController expect] rnn_setTabBarHideShadow:NO];
  24. [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleDefault];
  25. [[self.bindedViewController expect] rnn_setTabBarVisible:YES];
  26. [self.uut applyOptions:emptyOptions];
  27. [self.bindedViewController verify];
  28. }
  29. - (void)testApplyOptions_shouldSetInitialOptions {
  30. RNNNavigationOptions* initialOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  31. initialOptions.bottomTabs.testID = [[Text alloc] initWithValue:@"testID"];
  32. initialOptions.bottomTabs.backgroundColor = [[Color alloc] initWithValue:[UIColor redColor]];
  33. initialOptions.bottomTabs.translucent = [[Bool alloc] initWithValue:@(0)];
  34. initialOptions.bottomTabs.hideShadow = [[Bool alloc] initWithValue:@(1)];
  35. initialOptions.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
  36. initialOptions.bottomTabs.barStyle = [[Text alloc] initWithValue:@"black"];
  37. [[self.bindedViewController expect] rnn_setTabBarTestID:@"testID"];
  38. [[self.bindedViewController expect] rnn_setTabBarBackgroundColor:[UIColor redColor]];
  39. [[self.bindedViewController expect] rnn_setTabBarTranslucent:NO];
  40. [[self.bindedViewController expect] rnn_setTabBarHideShadow:YES];
  41. [[self.bindedViewController expect] rnn_setTabBarStyle:UIBarStyleBlack];
  42. [[self.bindedViewController expect] rnn_setTabBarVisible:NO];
  43. [self.uut applyOptions:initialOptions];
  44. [self.bindedViewController verify];
  45. }
  46. @end