react-native-navigation的迁移库

TopBarAppearancePresenterTest.m 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #import <XCTest/XCTest.h>
  2. #import <OCMock/OCMock.h>
  3. #import <ReactNativeNavigation/TopBarAppearancePresenter.h>
  4. #import "UIViewController+RNNOptions.h"
  5. #import <ReactNativeNavigation/RNNStackController.h>
  6. #import <ReactNativeNavigation/RNNComponentViewController.h>
  7. @interface TopBarAppearancePresenterTest : XCTestCase
  8. @end
  9. @implementation TopBarAppearancePresenterTest {
  10. TopBarAppearancePresenter* _uut;
  11. RNNStackController* _stack;
  12. RNNComponentViewController* _componentViewController;
  13. }
  14. - (void)setUp {
  15. [super setUp];
  16. _componentViewController = [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil];
  17. _stack = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:[[RNNNavigationOptions alloc] initEmptyOptions] presenter:_uut eventEmitter:nil childViewControllers:@[_componentViewController]];
  18. _uut = [[TopBarAppearancePresenter alloc] initWithNavigationController:_stack];
  19. }
  20. - (void)testMergeOptions_shouldMergeWithDefault {
  21. RNNNavigationOptions* mergeOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  22. RNNNavigationOptions* defaultOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  23. defaultOptions.topBar.title.color = [Color withColor:UIColor.redColor];
  24. mergeOptions.topBar.title.fontSize = [Number withValue:@(21)];
  25. RNNNavigationOptions* withDefault = [mergeOptions withDefault:defaultOptions];
  26. [_uut mergeOptions:mergeOptions.topBar withDefault:withDefault.topBar];
  27. XCTAssertEqual(_stack.navigationBar.standardAppearance.titleTextAttributes[NSForegroundColorAttributeName], UIColor.redColor);
  28. UIFont* font = _stack.navigationBar.standardAppearance.titleTextAttributes[NSFontAttributeName];
  29. XCTAssertEqual(font.pointSize, 21);
  30. }
  31. - (void)testApplyOptions_shouldSetBackButtonTestID {
  32. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
  33. options.topBar.backButton.testID = [Text withValue:@"TestID"];
  34. [_uut applyOptions:options.topBar];
  35. XCTAssertTrue([_componentViewController.navigationItem.backBarButtonItem.accessibilityIdentifier isEqualToString:@"TestID"]);
  36. }
  37. @end