react-native-navigation的迁移库

RNNNavigationOptionsTest.m 1.5KB

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