react-native-navigation的迁移库

RNNNavigationControllerPresenterTest.m 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
  20. [[_bindedViewController expect] rnn_setBackButtonColor:nil];
  21. [self.uut applyOptions:self.options];
  22. [_bindedViewController verify];
  23. }
  24. - (void)testApplyOptions_shouldSetBackButtonColor_withColor {
  25. self.options.topBar.backButton.color = [[Color alloc] initWithValue:[UIColor redColor]];
  26. [[_bindedViewController expect] rnn_setBackButtonColor:[UIColor redColor]];
  27. [self.uut applyOptions:self.options];
  28. [_bindedViewController verify];
  29. }
  30. - (void)testApplyOptionsBeforePoppingShouldSetTopBarBackgroundForPoppingViewController {
  31. _options.topBar.background.color = [[Color alloc] initWithValue:[UIColor redColor]];
  32. [[_bindedViewController expect] setTopBarBackgroundColor:_options.topBar.background.color.get];
  33. [self.uut applyOptionsBeforePopping:self.options];
  34. [_bindedViewController verify];
  35. }
  36. - (void)testApplyOptionsBeforePoppingShouldSetLargeTitleForPoppingViewController {
  37. _options.topBar.largeTitle.visible = [[Bool alloc] initWithBOOL:YES];
  38. [self.uut applyOptionsBeforePopping:self.options];
  39. XCTAssertTrue([[self.uut.boundViewController navigationBar] prefersLargeTitles]);
  40. }
  41. - (void)testApplyOptionsBeforePoppingShouldSetDefaultLargeTitleFalseForPoppingViewController {
  42. _options.topBar.largeTitle.visible = nil;
  43. [self.uut applyOptionsBeforePopping:self.options];
  44. XCTAssertFalse([[self.uut.boundViewController navigationBar] prefersLargeTitles]);
  45. }
  46. @end