react-native-navigation的迁移库

RNNNavigationControllerPresenterTest.m 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
  25. [[_bindedViewController expect] rnn_setBackButtonColor:nil];
  26. [self.uut applyOptions:self.options];
  27. [_bindedViewController verify];
  28. }
  29. - (void)testApplyOptions_shouldSetBackButtonColor_withColor {
  30. self.options.topBar.backButton.color = [[Color alloc] initWithValue:[UIColor redColor]];
  31. [[_bindedViewController expect] rnn_setBackButtonColor:[UIColor redColor]];
  32. [self.uut applyOptions:self.options];
  33. [_bindedViewController verify];
  34. }
  35. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withIcon {
  36. Image* image = [[Image alloc] initWithValue:[UIImage new]];
  37. self.options.topBar.backButton.icon = image;
  38. [[_bindedViewController expect] rnn_setBackButtonIcon:image.get withColor:nil title:nil];
  39. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  40. [_bindedViewController verify];
  41. }
  42. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withTitle {
  43. Text* title = [[Text alloc] initWithValue:@"Title"];
  44. self.options.topBar.backButton.title = title;
  45. [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:title.get];
  46. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  47. [_bindedViewController verify];
  48. }
  49. - (void)testApplyOptionsOnWillMoveToParent_shouldSetBackButtonOnBindedViewController_withHideTitle {
  50. Text* title = [[Text alloc] initWithValue:@"Title"];
  51. self.options.topBar.backButton.title = title;
  52. self.options.topBar.backButton.showTitle = [[Bool alloc] initWithValue:@(0)];
  53. [[_bindedViewController expect] rnn_setBackButtonIcon:nil withColor:nil title:@""];
  54. [self.uut applyOptionsOnWillMoveToParentViewController:self.options];
  55. [_bindedViewController verify];
  56. }
  57. @end