react-native-navigation的迁移库

RNNBasePresenterTest.m 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #import <XCTest/XCTest.h>
  2. #import "RNNBasePresenter.h"
  3. #import <OCMock/OCMock.h>
  4. #import "UIViewController+RNNOptions.h"
  5. @interface RNNBottomTabPresenterTest : XCTestCase
  6. @property (nonatomic, strong) RNNBasePresenter *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 = [[RNNBasePresenter 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_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController {
  26. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
  27. [self.uut applyOptions:self.options];
  28. [self.mockBindedViewController verify];
  29. }
  30. - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
  31. OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]);
  32. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  33. [[self.mockBindedViewController expect] rnn_setTabBarItemBadge:@"badge"];
  34. [self.uut applyOptions:self.options];
  35. [self.mockBindedViewController verify];
  36. }
  37. - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
  38. [self.uut bindViewController:self.mockBindedViewController];
  39. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  40. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:@"badge"];
  41. [self.uut applyOptions:self.options];
  42. [self.mockBindedViewController verify];
  43. }
  44. - (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
  45. [self.uut bindViewController:self.mockBindedViewController];
  46. self.options.bottomTab.badge = nil;
  47. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
  48. [self.uut applyOptions:self.options];
  49. [self.mockBindedViewController verify];
  50. }
  51. @end