-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathRNNButtonOptionsTest.mm
More file actions
84 lines (64 loc) · 2.53 KB
/
Copy pathRNNButtonOptionsTest.mm
File metadata and controls
84 lines (64 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#import <ReactNativeNavigation/RNNButtonOptions.h>
#import <XCTest/XCTest.h>
@interface RNNButtonOptionsTest : XCTestCase
@end
@implementation RNNButtonOptionsTest
- (void)testInitWithDict_shouldParseBackgroundColor {
RNNButtonOptions *options = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"backgroundColor" : @(0xffffff00),
}];
XCTAssertTrue(options.backgroundColor.hasValue);
XCTAssertTrue([options.backgroundColor.get isEqual:UIColor.yellowColor]);
}
- (void)testInitWithDict_shouldNotRequireBackgroundColor {
RNNButtonOptions *options = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"text" : @"title",
}];
XCTAssertFalse(options.backgroundColor.hasValue);
}
- (void)testCopy_shouldCopyBackgroundColor {
RNNButtonOptions *options = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"backgroundColor" : @(0xffffff00),
}];
RNNButtonOptions *copied = [options copy];
XCTAssertTrue(copied.backgroundColor.hasValue);
XCTAssertTrue([copied.backgroundColor.get isEqual:UIColor.yellowColor]);
}
- (void)testMergeOptions_shouldMergeBackgroundColor {
RNNButtonOptions *options = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"backgroundColor" : @(0xffffff00),
}];
RNNButtonOptions *mergeOptions = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"backgroundColor" : @(0xffff0000),
}];
[options mergeOptions:mergeOptions];
XCTAssertTrue([options.backgroundColor.get isEqual:UIColor.redColor]);
}
- (void)testMergeOptions_shouldNotOverwriteBackgroundColorWhenAbsent {
RNNButtonOptions *options = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"backgroundColor" : @(0xffffff00),
}];
RNNButtonOptions *mergeOptions = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
}];
[options mergeOptions:mergeOptions];
XCTAssertTrue([options.backgroundColor.get isEqual:UIColor.yellowColor]);
}
- (void)testWithDefault_shouldFallBackToDefaultBackgroundColor {
RNNButtonOptions *options = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
}];
RNNButtonOptions *defaults = [[RNNButtonOptions alloc] initWithDict:@{
@"id" : @"buttonId",
@"backgroundColor" : @(0xff00ff00),
}];
RNNButtonOptions *result = [options withDefault:defaults];
XCTAssertTrue([result.backgroundColor.get isEqual:UIColor.greenColor]);
}
@end