@@ -518,6 +518,38 @@ - (void) testgivenBoolean$setViewHierarchyEnabled_whenQuery_thenShouldCallNative
518
518
XCTAssertTrue (IBGBugReporting.shouldCaptureViewHierarchy );
519
519
}
520
520
521
+ /*
522
+ +------------------------------------------------------------------------+
523
+ | Feature Requets Module |
524
+ +------------------------------------------------------------------------+
525
+ */
526
+
527
+ - (void ) testgivenArgs $setEmailFieldRequiredForFeatureRequests_whenQuery_thenShouldCallNativeApi {
528
+ id mock = OCMClassMock ([IBGFeatureRequests class ]);
529
+ BOOL required = true ;
530
+ NSArray *actionTypesArray = [NSArray arrayWithObjects: @(IBGActionReportBug), nil ];
531
+ IBGAction actionTypes = 0 ;
532
+ for (NSNumber *boxedValue in actionTypesArray) {
533
+ actionTypes |= [boxedValue intValue ];
534
+ }
535
+ OCMStub ([mock setEmailFieldRequired: required forAction: actionTypes]);
536
+ [self .instabugBridge setEmailFieldRequiredForFeatureRequests: required forAction: actionTypesArray];
537
+ OCMVerify ([mock setEmailFieldRequired: required forAction: actionTypes]);
538
+ }
539
+
540
+ - (void ) testgive $showFeatureRequests_whenQuery_thenShouldCallNativeApi {
541
+ id mock = OCMClassMock ([IBGFeatureRequests class ]);
542
+ OCMStub ([mock show ]);
543
+ [self .instabugBridge showFeatureRequests ];
544
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Test ME PLX" ];
545
+
546
+ [[NSRunLoop mainRunLoop ] performBlock: ^{
547
+ OCMVerify ([mock show ]);
548
+ [expectation fulfill ];
549
+ }];
550
+
551
+ [self waitForExpectationsWithTimeout: EXPECTATION_TIMEOUT handler: nil ];
552
+ }
521
553
/*
522
554
+------------------------------------------------------------------------+
523
555
| Crash Reporting Module |
@@ -565,6 +597,67 @@ - (void)testShowChats {
565
597
[self waitForExpectationsWithTimeout: EXPECTATION_TIMEOUT handler: nil ];
566
598
}
567
599
600
+
601
+ /*
602
+ +------------------------------------------------------------------------+
603
+ | Replies module |
604
+ +------------------------------------------------------------------------+
605
+ */
606
+
607
+
608
+ - (void ) testgivenBoolean $setRepliesEnabled_whenQuery_thenShouldCallNativeApi {
609
+ BOOL enabled = false ;
610
+ [self .instabugBridge setRepliesEnabled: enabled];
611
+ XCTAssertFalse (IBGReplies.enabled );
612
+ }
613
+
614
+ // Since there is no way to check the invocation of the block 'callback' inside the block, 'IBGReplies.enabled' is set to false
615
+ // and the value is checked after callback execution to verify.
616
+ - (void ) testgivenCallback $hasChats_whenQuery_thenShouldCallNativeApi {
617
+ IBGReplies.enabled = true ;
618
+ RCTResponseSenderBlock callback = ^(NSArray *response) { IBGReplies.enabled = false ; };
619
+ [self .instabugBridge hasChats: callback];
620
+ XCTAssertFalse (IBGReplies.enabled );
621
+ }
622
+
623
+
624
+ - (void ) testgive $showReplies_whenQuery_thenShouldCallNativeApi {
625
+ id mock = OCMClassMock ([IBGReplies class ]);
626
+ OCMStub ([mock show ]);
627
+ [self .instabugBridge showReplies ];
628
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Test ME PLX" ];
629
+
630
+ [[NSRunLoop mainRunLoop ] performBlock: ^{
631
+ OCMVerify ([mock show ]);
632
+ [expectation fulfill ];
633
+ }];
634
+
635
+ [self waitForExpectationsWithTimeout: EXPECTATION_TIMEOUT handler: nil ];
636
+ }
637
+
638
+ - (void ) testgivenOnNewReplyReceivedCallback $setOnNewReplyReceivedCallback_whenQuery_thenShouldCallNativeApi {
639
+ id partialMock = OCMPartialMock (self.instabugBridge );
640
+ RCTResponseSenderBlock callback = ^(NSArray *response) {};
641
+ [partialMock setOnNewReplyReceivedCallback: callback];
642
+ XCTAssertNotNil (IBGReplies.didReceiveReplyHandler );
643
+
644
+ OCMStub ([partialMock sendEventWithName: @" IBGOnNewReplyReceivedCallback" body: nil ]);
645
+ IBGReplies.didReceiveReplyHandler ();
646
+ OCMVerify ([partialMock sendEventWithName: @" IBGOnNewReplyReceivedCallback" body: nil ]);
647
+ }
648
+
649
+ - (void ) testgivenCallback $getUnreadMessagesCount_whenQuery_thenShouldCallNativeApi {
650
+ IBGReplies.enabled = true ;
651
+ RCTResponseSenderBlock callback = ^(NSArray *response) { IBGReplies.enabled = false ; };
652
+ [self .instabugBridge getUnreadMessagesCount: callback];
653
+ XCTAssertFalse (IBGReplies.enabled );
654
+ }
655
+
656
+ - (void ) testgivenBoolean $setChatNotificationEnabled_whenQuery_thenShouldCallNativeApi {
657
+ BOOL enabled = false ;
658
+ [self .instabugBridge setChatNotificationEnabled: enabled];
659
+ XCTAssertFalse (IBGReplies.inAppNotificationsEnabled );
660
+ }
568
661
/*
569
662
+------------------------------------------------------------------------+
570
663
| Log Module |
0 commit comments