react-native-navigation的迁移库

RNNBottomTabPresenterTest.m 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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) UIViewController* bindedViewController;
  9. @property (nonatomic, strong) id mockBindedViewController;
  10. @end
  11. @implementation RNNBottomTabPresenterTest
  12. - (void)setUp {
  13. [super setUp];
  14. self.uut = [[RNNBottomTabPresenter alloc] init];
  15. self.bindedViewController = [UIViewController new];
  16. self.mockBindedViewController = [OCMockObject partialMockForObject:self.bindedViewController];
  17. [self.uut bindViewController:self.mockBindedViewController];
  18. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  19. }
  20. - (void)tearDown {
  21. [super tearDown];
  22. [self.mockBindedViewController stopMocking];
  23. self.bindedViewController = nil;
  24. }
  25. - (void)testApplyOptions_shouldSetTabBarItemBadgeWithDefaultWhenParentIsUITabBarController {
  26. OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]);
  27. [[self.mockBindedViewController expect] rnn_setTabBarItemBadge:nil];
  28. [self.uut applyOptions:self.options];
  29. [self.mockBindedViewController verify];
  30. }
  31. - (void)testApplyOptions_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController {
  32. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
  33. [self.uut applyOptions:self.options];
  34. [self.mockBindedViewController verify];
  35. }
  36. - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
  37. OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]);
  38. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  39. [[self.mockBindedViewController expect] rnn_setTabBarItemBadge:@"badge"];
  40. [self.uut applyOptions:self.options];
  41. [self.mockBindedViewController verify];
  42. }
  43. - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
  44. [self.uut bindViewController:self.mockBindedViewController];
  45. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  46. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:@"badge"];
  47. [self.uut applyOptions:self.options];
  48. [self.mockBindedViewController verify];
  49. }
  50. @end