react-native-navigation的迁移库

RNNBasePresenterTest.m 2.4KB

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