react-native-navigation的迁移库

RNNStackPresenterTest.m 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import "RNNStackPresenter.h"
  4. #import "UINavigationController+RNNOptions.h"
  5. #import "RNNStackController.h"
  6. @interface RNNStackPresenterTest : XCTestCase
  7. @property (nonatomic, strong) RNNStackPresenter *uut;
  8. @property (nonatomic, strong) RNNNavigationOptions *options;
  9. @property (nonatomic, strong) id boundViewController;
  10. @end
  11. @implementation RNNStackPresenterTest
  12. - (void)setUp {
  13. [super setUp];
  14. self.uut = [[RNNStackPresenter alloc] init];
  15. self.boundViewController = [OCMockObject partialMockForObject:[RNNStackController new]];
  16. [self.uut bindViewController:self.boundViewController];
  17. self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
  18. }
  19. - (void)testApplyOptions_shouldSetBackButtonColor_withDefaultValues {
  20. [[_boundViewController expect] setBackButtonColor:nil];
  21. [self.uut applyOptions:self.options];
  22. [_boundViewController verify];
  23. }
  24. - (void)testApplyOptions_shouldSetBackButtonColor_withColor {
  25. self.options.topBar.backButton.color = [[Color alloc] initWithValue:[UIColor redColor]];
  26. [[_boundViewController expect] setBackButtonColor:[UIColor redColor]];
  27. [self.uut applyOptions:self.options];
  28. [_boundViewController verify];
  29. }
  30. - (void)testApplyOptionsBeforePoppingShouldSetTopBarBackgroundForPoppingViewController {
  31. _options.topBar.background.color = [[Color alloc] initWithValue:[UIColor redColor]];
  32. [[_boundViewController expect] setTopBarBackgroundColor:_options.topBar.background.color.get];
  33. [self.uut applyOptionsBeforePopping:self.options];
  34. [_boundViewController 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