Browse Source

Improve unit tests code coverage on ios

yogevbd 6 years ago
parent
commit
4a676113a4

+ 0
- 2
lib/ios/ReactNativeNavigationTests/RNNNavigationStackManagerTest.m View File

@@ -5,7 +5,6 @@
5 5
 
6 6
 @interface RNNNavigationStackManagerTest : XCTestCase
7 7
 
8
-@property (nonatomic, strong) RNNStore *store;
9 8
 @property (nonatomic, strong) UINavigationController *nvc;
10 9
 @property (nonatomic, strong) UIViewController *vc1;
11 10
 @property (nonatomic, strong) UIViewController *vc2;
@@ -18,7 +17,6 @@
18 17
 
19 18
 - (void)setUp {
20 19
     [super setUp];
21
-	self.store = [RNNStore new];
22 20
 	
23 21
 	self.nvc = [[UINavigationController alloc] init];
24 22
 	self.vc1 = [RNNRootViewController new];

+ 7
- 0
lib/ios/ReactNativeNavigationTests/RNNOverlayManagerTest.m View File

@@ -51,4 +51,11 @@
51 51
 	XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
52 52
 }
53 53
 
54
+- (void)testDismissOverlayShouldNotRemoveWrongVC {
55
+	[_overlayManager showOverlay:_overlayVC];
56
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
57
+	[_overlayManager dismissOverlay:[UIViewController new]];
58
+	XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
59
+}
60
+
54 61
 @end

+ 21
- 0
lib/ios/ReactNativeNavigationTests/RNNStoreTest.m View File

@@ -87,6 +87,27 @@
87 87
 	XCTAssertNil([self.store findComponentForId:@"cntId1"]);
88 88
 }
89 89
 
90
+- (void)testGetExternalComponentShouldRetrunSavedComponent {
91
+	UIViewController* testVC = [UIViewController new];
92
+	NSString *externalComponentId = @"extId1";
93
+	[self.store registerExternalComponent:externalComponentId callback:^UIViewController *(NSDictionary *props, RCTBridge *bridge) {
94
+		return testVC;
95
+	}];
96
+	
97
+	UIViewController* savedComponent = [self.store getExternalComponent:externalComponentId props:nil bridge:nil];
98
+	XCTAssertEqual(testVC, savedComponent);
99
+}
100
+
101
+- (void)testComponentKeyForInstance_UknownComponentShouldReturnNil {
102
+	id result = [self.store componentKeyForInstance:[UIViewController new]];
103
+	XCTAssertNil(result);
104
+}
105
+
106
+-(void)testCleanStore {
107
+	[self.store clean];
108
+	XCTAssertFalse(self.store.pendingModalIdsToDismiss.count);
109
+	XCTAssertFalse(self.store.isReadyToReceiveCommands);
110
+}
90 111
 
91 112
 #pragma mark - private
92 113