Commit 1d5f6b2d authored by Yogev Ben David's avatar Yogev Ben David Committed by GitHub

Merge pull request #354 from wix/testCoverage

Add test coverage on iOS
parents 4674f8ec dbf046ef
...@@ -192,17 +192,9 @@ ...@@ -192,17 +192,9 @@
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
50002A7222E8874F008F6742 /* Utils */ = {
isa = PBXGroup;
children = (
);
path = Utils;
sourceTree = "<group>";
};
504D54BC22E4B83E0088F2E4 /* Integration */ = { 504D54BC22E4B83E0088F2E4 /* Integration */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
50002A7222E8874F008F6742 /* Utils */,
504D54BD22E4B8660088F2E4 /* RNBridgeModuleIntegrationTest.m */, 504D54BD22E4B8660088F2E4 /* RNBridgeModuleIntegrationTest.m */,
50002A4C22E88266008F6742 /* RNCommandsHandlerIntegrationTest.m */, 50002A4C22E88266008F6742 /* RNCommandsHandlerIntegrationTest.m */,
); );
......
...@@ -68,6 +68,28 @@ ...@@ -68,6 +68,28 @@
[_mockedNotificationCenter verify]; [_mockedNotificationCenter verify];
} }
- (void)testDidReceiveNotificationResponse_ShouldEmitEvent {
UNNotification* notification = [self createNotificationWithIdentifier:@"id" andUserInfo:@{@"extraKey": @"extraValue"}];
UNNotificationResponse* response = [self createNotificationResponseWithIdentifier:@"id" andNotification:notification];
void (^testBlock)(void) = ^void() {};
[[_mockedNotificationCenter expect] postNotificationName:RNNotificationOpened object:[OCMArg any] userInfo:[OCMArg checkWithBlock:^BOOL(id obj) {
return ([[obj valueForKey:@"identifier"] isEqualToString:@"id"] &&
[[[obj valueForKey:@"payload"] valueForKey:@"extraKey"] isEqualToString:@"extraValue"]);
}]];
[_uut didReceiveNotificationResponse:response completionHandler:testBlock];
[_mockedNotificationCenter verify];
}
- (void)testDidReceiveNotificationResponse_ShouldSaveCompletionBlockToStore {
UNNotification* notification = [self createNotificationWithIdentifier:@"id" andUserInfo:@{@"extraKey": @"extraValue"}];
UNNotificationResponse* response = [self createNotificationResponseWithIdentifier:@"id" andNotification:notification];
void (^testBlock)(void) = ^void() {};
[_uut didReceiveNotificationResponse:response completionHandler:testBlock];
XCTAssertEqual([_store getActionCompletionHandler:@"id"], testBlock);
}
- (UNNotification *)createNotificationWithIdentifier:(NSString *)identifier andUserInfo:(NSDictionary *)userInfo { - (UNNotification *)createNotificationWithIdentifier:(NSString *)identifier andUserInfo:(NSDictionary *)userInfo {
UNNotification* notification = [OCMockObject niceMockForClass:[UNNotification class]]; UNNotification* notification = [OCMockObject niceMockForClass:[UNNotification class]];
UNNotificationContent* content = [OCMockObject niceMockForClass:[UNNotificationContent class]]; UNNotificationContent* content = [OCMockObject niceMockForClass:[UNNotificationContent class]];
...@@ -79,6 +101,14 @@ ...@@ -79,6 +101,14 @@
return notification; return notification;
} }
- (UNNotificationResponse *)createNotificationResponseWithIdentifier:(NSString *)identifier andNotification:(UNNotification *)notification {
UNNotificationResponse* notificationResponse = [OCMockObject niceMockForClass:[UNNotificationResponse class]];
OCMStub(notificationResponse.actionIdentifier).andReturn(identifier);
OCMStub(notificationResponse.notification).andReturn(notification);
return notificationResponse;
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment