Skip to content

Commit 4d5097e

Browse files
Add native ios tests for Chats module
1 parent 99f454d commit 4d5097e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

InstabugSample/ios/InstabugSampleTests/InstabugSampleTests.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,5 +528,35 @@ - (void)testSetCrashReportingEnabled {
528528
XCTAssertFalse(IBGCrashReporting.enabled);
529529
}
530530

531+
/*
532+
+------------------------------------------------------------------------+
533+
| Chats Module |
534+
+------------------------------------------------------------------------+
535+
*/
536+
537+
- (void)testSetChatsEnabled {
538+
id mock = OCMClassMock([Instabug class]);
539+
540+
[self.instabugBridge setChatsEnabled:YES];
541+
XCTAssertTrue(IBGChats.enabled);
542+
543+
[self.instabugBridge setChatsEnabled:NO];
544+
XCTAssertFalse(IBGChats.enabled);
545+
}
546+
547+
- (void)testShowChats {
548+
id mock = OCMClassMock([IBGChats class]);
549+
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing [IBGChats showChats]"];
550+
551+
OCMStub([mock show]);
552+
[self.instabugBridge showChats];
553+
554+
[[NSRunLoop mainRunLoop] performBlock:^{
555+
OCMVerify([mock show]);
556+
[expectation fulfill];
557+
}];
558+
559+
[self waitForExpectationsWithTimeout:EXPECTATION_TIMEOUT handler:nil];
560+
}
531561

532562
@end

ios/RNInstabug/InstabugReactBridge.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,13 @@
126126

127127
- (void)setCrashReportingEnabled:(BOOL)enabledCrashReporter;
128128

129+
/*
130+
+------------------------------------------------------------------------+
131+
| Chats Module |
132+
+------------------------------------------------------------------------+
133+
*/
134+
135+
- (void)setChatsEnabled:(BOOL)isEnabled;
136+
- (void)showChats;
137+
129138
@end

0 commit comments

Comments
 (0)