react-native-navigation的迁移库

RNNNavigationOptionsTest.m 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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": @{@"backgroundColor" : @(0xff0000ff)}}];
  15. XCTAssertTrue(options.topBar.backgroundColor);
  16. }
  17. -(void)testThrowsWhenStyleDoesNotExist{
  18. XCTAssertThrows([[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"someColor" : @(0xff0000ff)}}]);
  19. }
  20. -(void)testChangeRNNNavigationOptionsDynamically{
  21. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"backgroundColor" : @(0xff0000ff)}}];
  22. NSDictionary* dynamicOptions = @{@"topBar": @{@"textColor" : @(0xffff00ff), @"title" : @"hello"}};
  23. [options mergeWith:dynamicOptions];
  24. XCTAssertTrue([options.topBar.title isEqual:@"hello"]);
  25. }
  26. -(void)testChangeRNNNavigationOptionsWithInvalidProperties{
  27. RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBar": @{@"backgroundColor" : @(0xff0000ff)}}];
  28. NSDictionary* dynamicOptions = @{@"topBar": @{@"titleeeee" : @"hello"}};
  29. XCTAssertThrows([options mergeWith:dynamicOptions]);
  30. }
  31. @end