react-native-navigation的迁移库

RNNBasePresenterTest.m 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #import <XCTest/XCTest.h>
  2. #import "RNNBasePresenter.h"
  3. #import <OCMock/OCMock.h>
  4. #import "UIViewController+RNNOptions.h"
  5. #import "RNNRootViewController.h"
  6. @interface RNNBottomTabPresenterTest : XCTestCase
  7. @property (nonatomic, strong) RNNBasePresenter *uut;
  8. @property (nonatomic, strong) RNNNavigationOptions *options;
  9. @property (nonatomic, strong) RNNRootViewController* bindedViewController;
  10. @property (nonatomic, strong) id mockBindedViewController;
  11. @end
  12. @implementation RNNBottomTabPresenterTest
  13. - (void)setUp {
  14. [super setUp];
  15. self.uut = [[RNNBasePresenter alloc] init];
  16. self.bindedViewController = [RNNRootViewController new];
  17. self.mockBindedViewController = [OCMockObject partialMockForObject:self.bindedViewController];
  18. [self.uut bindViewController:self.mockBindedViewController];
  19. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  20. }
  21. - (void)tearDown {
  22. [super tearDown];
  23. [self.mockBindedViewController stopMocking];
  24. self.bindedViewController = nil;
  25. }
  26. - (void)testApplyOptions_shouldSetTabBarItemBadgeOnlyWhenParentIsUITabBarController {
  27. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
  28. [self.uut applyOptions:self.options];
  29. [self.mockBindedViewController verify];
  30. }
  31. - (void)testApplyOptions_shouldSetTabBarItemBadgeWithValue {
  32. OCMStub([self.mockBindedViewController parentViewController]).andReturn([UITabBarController new]);
  33. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  34. [[self.mockBindedViewController expect] rnn_setTabBarItemBadge:@"badge"];
  35. [self.uut applyOptions:self.options];
  36. [self.mockBindedViewController verify];
  37. }
  38. - (void)testApplyOptions_setTabBarItemBadgeShouldNotCalledOnUITabBarController {
  39. [self.uut bindViewController:self.mockBindedViewController];
  40. self.options.bottomTab.badge = [[Text alloc] initWithValue:@"badge"];
  41. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:@"badge"];
  42. [self.uut applyOptions:self.options];
  43. [self.mockBindedViewController verify];
  44. }
  45. - (void)testApplyOptions_setTabBarItemBadgeShouldWhenNoValue {
  46. [self.uut bindViewController:self.mockBindedViewController];
  47. self.options.bottomTab.badge = nil;
  48. [[self.mockBindedViewController reject] rnn_setTabBarItemBadge:[OCMArg any]];
  49. [self.uut applyOptions:self.options];
  50. [self.mockBindedViewController verify];
  51. }
  52. @end