Commit dbf046ef authored by yogevbd's avatar yogevbd

Add test coverage for iOS

parent df79658e
......@@ -192,17 +192,9 @@
name = Products;
sourceTree = "<group>";
};
50002A7222E8874F008F6742 /* Utils */ = {
isa = PBXGroup;
children = (
);
path = Utils;
sourceTree = "<group>";
};
504D54BC22E4B83E0088F2E4 /* Integration */ = {
isa = PBXGroup;
children = (
50002A7222E8874F008F6742 /* Utils */,
504D54BD22E4B8660088F2E4 /* RNBridgeModuleIntegrationTest.m */,
50002A4C22E88266008F6742 /* RNCommandsHandlerIntegrationTest.m */,
);
......
......@@ -68,6 +68,28 @@
[_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* notification = [OCMockObject niceMockForClass:[UNNotification class]];
UNNotificationContent* content = [OCMockObject niceMockForClass:[UNNotificationContent class]];
......@@ -79,6 +101,14 @@
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
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