react-native-navigation的迁移库

UINavigationController+RNNOptionsTest.m 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #import <XCTest/XCTest.h>
  2. #import "UINavigationController+RNNOptions.h"
  3. @interface UINavigationController_RNNOptionsTest : XCTestCase
  4. @end
  5. @implementation UINavigationController_RNNOptionsTest
  6. - (void)setUp {
  7. [super setUp];
  8. }
  9. - (void)testSetBackButtonIcon_withColor_shouldSetColor {
  10. UIViewController* vc = [UIViewController new];
  11. UINavigationController* uut = [[UINavigationController alloc] initWithRootViewController:vc];
  12. UIColor* color = [UIColor blackColor];
  13. [uut setBackButtonIcon:nil withColor:color title:nil showTitle:nil];
  14. XCTAssertEqual(color, vc.navigationItem.backBarButtonItem.tintColor);
  15. }
  16. - (void)testSetBackButtonIcon_withColor_shouldSetTitle {
  17. UIViewController* vc = [UIViewController new];
  18. UINavigationController* uut = [[UINavigationController alloc] initWithRootViewController:vc];
  19. NSString* title = @"Title";
  20. [uut setBackButtonIcon:nil withColor:nil title:title showTitle:YES];
  21. XCTAssertEqual(title, vc.navigationItem.backBarButtonItem.title);
  22. }
  23. //- (void)testSetBackButtonIcon_withColor_shouldSetIcon {
  24. // UIViewController* vc = [UIViewController new];
  25. // UINavigationController* uut = [[UINavigationController alloc] initWithRootViewController:vc];
  26. // UIImage* icon = [UIImage new];
  27. //
  28. // [uut setBackButtonIcon:icon withColor:nil title:nil showTitle:nil];
  29. // XCTAssertEqual(icon, vc.navigationItem.backBarButtonItem.image);
  30. //}
  31. - (void)testSetBackButtonIcon_shouldSetTitleOnPreviousViewControllerIfExists {
  32. UIViewController* viewController1 = [UIViewController new];
  33. UIViewController* viewController2 = [UIViewController new];
  34. UINavigationController* uut = [[UINavigationController alloc] init];
  35. [uut setViewControllers:@[viewController1, viewController2]];
  36. NSString* title = @"Title";
  37. [uut setBackButtonIcon:nil withColor:nil title:title showTitle:YES];
  38. XCTAssertEqual(title, viewController1.navigationItem.backBarButtonItem.title);
  39. }
  40. @end