react-native-navigation的迁移库

RNNNavigationOptionsTest.m 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #import <XCTest/XCTest.h>
  2. #import "RNNNavigationOptions.h"
  3. @interface RNNNavigationOptionsTest : XCTestCase
  4. @end
  5. @implementation RNNNavigationOptionsTest
  6. - (void)setUp {
  7. [super setUp];
  8. }
  9. - (void)testInitCreatesInstanceType {
  10. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{}];
  11. XCTAssertTrue([options isKindOfClass:[RNNNavigationOptions class]]);
  12. }
  13. - (void)testAddsStyleFromDictionaryWithInit {
  14. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"background" : @{@"color" : @(0xff0000ff)}}}];
  15. XCTAssertTrue(options.topBar.background.color);
  16. }
  17. - (void)testChangeRNNNavigationOptionsDynamically {
  18. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"background" : @{@"color" : @(0xff0000ff)}}}];
  19. NSDictionary* dynamicOptionsDict = @{@"topBar": @{@"textColor" : @(0xffff00ff), @"title" : @{@"text": @"hello"}}};
  20. RNNNavigationOptions* dynamicOptions = [[RNNNavigationOptions alloc] initWithDict:dynamicOptionsDict];
  21. [options overrideOptions:dynamicOptions];
  22. XCTAssertTrue([options.topBar.title.text.get isEqual:@"hello"]);
  23. }
  24. - (void)testChangeRNNNavigationOptionsWithInvalidProperties {
  25. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"background" : @{@"color" : @(0xff0000ff)}}}];
  26. NSDictionary* dynamicOptionsDict = @{@"topBar": @{@"titleeeee" : @"hello"}};
  27. RNNNavigationOptions* dynamicOptions = [[RNNNavigationOptions alloc] initWithDict:dynamicOptionsDict];
  28. XCTAssertNoThrow([options overrideOptions:dynamicOptions]);
  29. }
  30. //
  31. //- (void)test_applyDefaultOptions {
  32. // RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
  33. // UIViewController* viewController = [UIViewController new];
  34. // UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  35. // UITabBarController* tabBarController = [[UITabBarController alloc] init];
  36. // [tabBarController setViewControllers:@[navigationController]];
  37. //
  38. // [options applyDefaultOptionsOn:viewController];
  39. //
  40. // XCTAssertFalse(navigationController.navigationBar.hidden);
  41. // XCTAssertFalse(navigationController.navigationBar.translucent);
  42. // XCTAssertFalse(navigationController.navigationBar.clipsToBounds);
  43. // XCTAssertFalse(navigationController.hidesBarsOnSwipe);
  44. // XCTAssertTrue(navigationController.navigationBar.barStyle == UIBarStyleDefault);
  45. //
  46. // XCTAssertNil(tabBarController.tabBar.barTintColor);
  47. // XCTAssertTrue(tabBarController.tabBar.barStyle == UIBarStyleDefault);
  48. // XCTAssertFalse(tabBarController.tabBar.translucent);
  49. //}
  50. @end