react-native-navigation的迁移库

TopBarAppearancePresenterTest.m 1.5KB

12345678910111213141516171819202122232425262728293031323334353637
  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. @interface TopBarAppearancePresenterTest : XCTestCase
  7. @end
  8. @implementation TopBarAppearancePresenterTest {
  9. TopBarAppearancePresenter* _uut;
  10. RNNStackController* _stack;
  11. }
  12. - (void)setUp {
  13. [super setUp];
  14. _stack = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:[[RNNNavigationOptions alloc] initEmptyOptions] presenter:_uut eventEmitter:nil childViewControllers:@[]];
  15. _uut = [[TopBarAppearancePresenter alloc] initWithNavigationController:_stack];
  16. }
  17. - (void)testMergeOptions_shouldMergeWithDefault {
  18. RNNNavigationOptions* mergeOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  19. RNNNavigationOptions* defaultOptions = [[RNNNavigationOptions alloc] initEmptyOptions];
  20. defaultOptions.topBar.title.color = [Color withColor:UIColor.redColor];
  21. mergeOptions.topBar.title.fontSize = [Number withValue:@(21)];
  22. RNNNavigationOptions* withDefault = [mergeOptions withDefault:defaultOptions];
  23. [_uut mergeOptions:mergeOptions.topBar withDefault:withDefault.topBar];
  24. XCTAssertEqual(_stack.navigationBar.standardAppearance.titleTextAttributes[NSForegroundColorAttributeName], UIColor.redColor);
  25. UIFont* font = _stack.navigationBar.standardAppearance.titleTextAttributes[NSFontAttributeName];
  26. XCTAssertEqual(font.pointSize, 21);
  27. }
  28. @end