Ver código fonte

Added tests for drawBehind

yogevbd 6 anos atrás
pai
commit
9e6976d962

+ 44
- 5
lib/ios/ReactNativeNavigationTests/UIViewController+RNNOptionsTest.m Ver arquivo

@@ -1,9 +1,10 @@
1 1
 #import <XCTest/XCTest.h>
2 2
 #import "UIViewController+RNNOptions.h"
3
+#import <OCMock/OCMock.h>
3 4
 
4 5
 @interface UIViewController_RNNOptionsTest : XCTestCase
5 6
 
6
-@property (nonatomic, retain) UIViewController* uut;
7
+@property (nonatomic, retain) id uut;
7 8
 
8 9
 @end
9 10
 
@@ -11,27 +12,65 @@
11 12
 
12 13
 - (void)setUp {
13 14
     [super setUp];
14
-	self.uut = [UIViewController new];
15
+	self.uut = [OCMockObject partialMockForObject:[UIViewController new]];
15 16
 }
16 17
 
17 18
 - (void)test_setTabBarItemBadge_shouldSetValidValue {
18 19
 	NSString* badgeValue = @"badge";
19 20
 	[self.uut rnn_setTabBarItemBadge:badgeValue];
20
-	XCTAssertEqual(self.uut.tabBarItem.badgeValue, badgeValue);
21
+	XCTAssertEqual([self.uut tabBarItem].badgeValue, badgeValue);
21 22
 }
22 23
 
23 24
 - (void)test_setTabBarItemBadge_shouldResetWhenValueIsEmptyString {
24 25
 	[self.uut rnn_setTabBarItemBadge:@"badge"];
25 26
 	NSString* badgeValue = @"";
26 27
 	[self.uut rnn_setTabBarItemBadge:badgeValue];
27
-	XCTAssertEqual(self.uut.tabBarItem.badgeValue, nil);
28
+	XCTAssertEqual([self.uut tabBarItem].badgeValue, nil);
28 29
 }
29 30
 
30 31
 - (void)test_setTabBarItemBadge_shouldResetWhenValueIsNullObject {
31 32
 	[self.uut rnn_setTabBarItemBadge:@"badge"];
32 33
 	NSNull* nullBadgeValue = [NSNull new];
33 34
 	[self.uut rnn_setTabBarItemBadge:nullBadgeValue];
34
-	XCTAssertEqual(self.uut.tabBarItem.badgeValue, nil);
35
+	XCTAssertEqual([self.uut tabBarItem].badgeValue, nil);
35 36
 }
36 37
 
38
+- (void)testSetDrawBehindTopBarTrue_shouldSetExtendedLayoutTrue {
39
+    [[self.uut expect] setExtendedLayoutIncludesOpaqueBars:YES];
40
+    [self.uut rnn_setDrawBehindTopBar:YES];
41
+    [self.uut verify];
42
+}
43
+
44
+- (void)testSetDrawBehindTabBarTrue_shouldSetExtendedLayoutTrue {
45
+    [[self.uut expect] setExtendedLayoutIncludesOpaqueBars:YES];
46
+    [self.uut rnn_setDrawBehindTabBar:YES];
47
+    [self.uut verify];
48
+}
49
+
50
+- (void)testSetDrawBehindTopBarFalse_shouldNotCallExtendedLayout {
51
+    [[self.uut reject] setExtendedLayoutIncludesOpaqueBars:NO];
52
+    [self.uut rnn_setDrawBehindTopBar:NO];
53
+    [self.uut verify];
54
+}
55
+
56
+- (void)testSetDrawBehindTabBarFalse_shouldNotCallExtendedLayout {
57
+    [[self.uut reject] setExtendedLayoutIncludesOpaqueBars:NO];
58
+    [self.uut rnn_setDrawBehindTabBar:NO];
59
+    [self.uut verify];
60
+}
61
+
62
+- (void)testSetDrawBehindTopBarFalse_shouldSetCorrectEdgesForExtendedLayout {
63
+	[self.uut rnn_setDrawBehindTopBar:NO];
64
+    UIRectEdge expectedRectEdge = UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight;
65
+    XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
66
+}
67
+
68
+- (void)testSetDrawBehindTapBarFalse_shouldSetCorrectEdgesForExtendedLayout {
69
+    [self.uut rnn_setDrawBehindTabBar:NO];
70
+	UIRectEdge expectedRectEdge = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight;
71
+	XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
72
+}
73
+
74
+
75
+
37 76
 @end