Skip to content

Commit

Permalink
Fix iOS Test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBuggedYRN committed Feb 7, 2023
1 parent ec3eaf9 commit 7e11ffc
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions example/ios/InstabugTests/InstabugBugReportingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,49 @@ - (void) testgivenHandler$setOnInvokeHandler_whenQuery_thenShouldCallNativeApi {

- (void) testgivenHandlerCANCEL$setOnDismissHandler_whenQuery_thenShouldCallNativeApi {
id partialMock = OCMPartialMock(self.instabugBridge);
IBGDismissType dismissType = IBGDismissTypeCancel;
IBGReportType reportType = IBGReportTypeBug;

RCTResponseSenderBlock callback = ^(NSArray *response) {};
[partialMock setOnDismissHandler:callback];
XCTAssertNotNil(IBGBugReporting.didDismissHandler);
NSDictionary *result = @{ @"dismissType": @"CANCEL",
@"reportType": @"bug"};
NSDictionary *result = @{ @"dismissType": @(dismissType),
@"reportType": @(reportType)};

OCMStub([partialMock sendEventWithName:@"IBGpostInvocationHandler" body:result]);
IBGBugReporting.didDismissHandler(IBGDismissTypeCancel,IBGReportTypeBug);
IBGBugReporting.didDismissHandler(dismissType, reportType);
OCMVerify([partialMock sendEventWithName:@"IBGpostInvocationHandler" body:result]);
}

- (void) testgivenHandlerSUBMIT$setOnDismissHandler_whenQuery_thenShouldCallNativeApi {
id partialMock = OCMPartialMock(self.instabugBridge);
IBGDismissType dismissType = IBGDismissTypeSubmit;
IBGReportType reportType = IBGReportTypeFeedback;

RCTResponseSenderBlock callback = ^(NSArray *response) {};
[partialMock setOnDismissHandler:callback];
XCTAssertNotNil(IBGBugReporting.didDismissHandler);

NSDictionary *result = @{ @"dismissType": @"SUBMIT",
@"reportType": @"feedback"};
NSDictionary *result = @{ @"dismissType": @(dismissType),
@"reportType": @(reportType)};

OCMStub([partialMock sendEventWithName:@"IBGpostInvocationHandler" body:result]);
IBGBugReporting.didDismissHandler(IBGDismissTypeSubmit,IBGReportTypeFeedback);
IBGBugReporting.didDismissHandler(dismissType, reportType);
OCMVerify([partialMock sendEventWithName:@"IBGpostInvocationHandler" body:result]);
}

- (void) testgivenHandlerADD_ATTACHMENT$setOnDismissHandler_whenQuery_thenShouldCallNativeApi {
id partialMock = OCMPartialMock(self.instabugBridge);
IBGDismissType dismissType = IBGDismissTypeAddAttachment;
IBGReportType reportType = IBGReportTypeFeedback;

RCTResponseSenderBlock callback = ^(NSArray *response) {};
[partialMock setOnDismissHandler:callback];
XCTAssertNotNil(IBGBugReporting.didDismissHandler);
NSDictionary *result = @{ @"dismissType": @"ADD_ATTACHMENT",
@"reportType": @"feedback"};
NSDictionary *result = @{ @"dismissType": @(dismissType),
@"reportType": @(reportType)};

OCMStub([partialMock sendEventWithName:@"IBGpostInvocationHandler" body:result]);
IBGBugReporting.didDismissHandler(IBGDismissTypeAddAttachment,IBGReportTypeFeedback);
IBGBugReporting.didDismissHandler(dismissType, reportType);
OCMVerify([partialMock sendEventWithName:@"IBGpostInvocationHandler" body:result]);
}

Expand Down

0 comments on commit 7e11ffc

Please sign in to comment.