Skip to content

Commit 3d84b7d

Browse files
Add native ios tests for Log module
1 parent 4d5097e commit 3d84b7d

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

InstabugSample/ios/InstabugSampleTests/InstabugSampleTests.m

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,4 +559,68 @@ - (void)testShowChats {
559559
[self waitForExpectationsWithTimeout:EXPECTATION_TIMEOUT handler:nil];
560560
}
561561

562+
/*
563+
+------------------------------------------------------------------------+
564+
| Log Module |
565+
+------------------------------------------------------------------------+
566+
*/
567+
568+
- (void)testSetIBGLogPrintsToConsole {
569+
[self.instabugBridge setIBGLogPrintsToConsole:YES];
570+
XCTAssertTrue(IBGLog.printsToConsole);
571+
}
572+
573+
- (void)testLogVerbose {
574+
id mock = OCMClassMock([IBGLog class]);
575+
NSString *log = @"some log";
576+
577+
OCMStub([mock logVerbose:log]);
578+
[self.instabugBridge logVerbose:log];
579+
OCMVerify([mock logVerbose:log]);
580+
}
581+
582+
- (void)testLogDebug {
583+
id mock = OCMClassMock([IBGLog class]);
584+
NSString *log = @"some log";
585+
586+
OCMStub([mock logDebug:log]);
587+
[self.instabugBridge logDebug:log];
588+
OCMVerify([mock logDebug:log]);
589+
}
590+
591+
- (void)testLogInfo {
592+
id mock = OCMClassMock([IBGLog class]);
593+
NSString *log = @"some log";
594+
595+
OCMStub([mock logInfo:log]);
596+
[self.instabugBridge logInfo:log];
597+
OCMVerify([mock logInfo:log]);
598+
}
599+
600+
- (void)testLogWarn {
601+
id mock = OCMClassMock([IBGLog class]);
602+
NSString *log = @"some log";
603+
604+
OCMStub([mock logWarn:log]);
605+
[self.instabugBridge logWarn:log];
606+
OCMVerify([mock logWarn:log]);
607+
}
608+
609+
- (void)testLogError {
610+
id mock = OCMClassMock([IBGLog class]);
611+
NSString *log = @"some log";
612+
613+
OCMStub([mock logError:log]);
614+
[self.instabugBridge logError:log];
615+
OCMVerify([mock logError:log]);
616+
}
617+
618+
- (void)testClearLogs {
619+
id mock = OCMClassMock([IBGLog class]);
620+
621+
OCMStub([mock clearAllLogs]);
622+
[self.instabugBridge clearLogs];
623+
OCMVerify([mock clearAllLogs]);
624+
}
625+
562626
@end

ios/RNInstabug/InstabugReactBridge.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,18 @@
135135
- (void)setChatsEnabled:(BOOL)isEnabled;
136136
- (void)showChats;
137137

138+
/*
139+
+------------------------------------------------------------------------+
140+
| Log Module |
141+
+------------------------------------------------------------------------+
142+
*/
143+
144+
- (void)setIBGLogPrintsToConsole:(BOOL)printsToConsole;
145+
- (void)logVerbose:(NSString *)log;
146+
- (void)logDebug:(NSString *)log;
147+
- (void)logInfo:(NSString *)log;
148+
- (void)logWarn:(NSString *)log;
149+
- (void)logError:(NSString *)log;
150+
- (void)clearLogs;
151+
138152
@end

0 commit comments

Comments
 (0)