react-native-navigation的迁移库

TopBarAppearancePresenterTest.m 2.2KB

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