react-native-navigation的迁移库

RNNNavigationControllerPresenterTest.m 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNNavigationControllerPresenter.h"
  4. #import "UINavigationController+RNNOptions.h"
  5. #import "RNNNavigationController.h"
  6. @interface RNNNavigationControllerPresenterTest : XCTestCase
  7. @property (nonatomic, strong) RNNNavigationControllerPresenter *uut;
  8. @property (nonatomic, strong) RNNNavigationOptions *options;
  9. @property (nonatomic, strong) id bindedViewController;
  10. @end
  11. @implementation RNNNavigationControllerPresenterTest
  12. - (void)setUp {
  13. [super setUp];
  14. self.uut = [[RNNNavigationControllerPresenter alloc] init];
  15. self.bindedViewController = [OCMockObject partialMockForObject:[RNNNavigationController new]];
  16. [self.uut bindViewController:self.bindedViewController];
  17. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  18. }
  19. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withDefaultValues {
  20. [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:nil];
  21. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  22. [_bindedViewController verify];
  23. }
  24. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withIcon {
  25. Image* image = [[Image alloc] initWithValue:[UIImage new]];
  26. self.options.topBar.backButton.icon = image;
  27. [[_bindedViewController expect] rnn_setBackButtonIcon:image.get withColor:nil title:nil];
  28. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  29. [_bindedViewController verify];
  30. }
  31. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withTitle {
  32. Text* title = [[Text alloc] initWithValue:@"Title"];
  33. self.options.topBar.backButton.title = title;
  34. [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:title.get];
  35. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  36. [_bindedViewController verify];
  37. }
  38. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withHideTitle {
  39. Text* title = [[Text alloc] initWithValue:@"Title"];
  40. self.options.topBar.backButton.title = title;
  41. self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
  42. [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:@""];
  43. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  44. [_bindedViewController verify];
  45. }
  46. @end