Skip to content

Commit d2bd2e4

Browse files
committed
make sure failure block is called in send tags bad input unit test
1 parent b72b3f2 commit d2bd2e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,15 +1388,23 @@ - (void)testSendBadObjectInTags {
13881388
[UnitTestCommonMethods initOneSignal_andThreadWait];
13891389

13901390
XCTAssertEqual(OneSignalClientOverrider.networkRequestCount, 2);
1391+
XCTestExpectation *errorExpectation = [self expectationWithDescription:@"onesignal_failure_block_called"];
1392+
errorExpectation.expectedFulfillmentCount = 1;
13911393
//The OneSignal class is not a valid json object
1392-
[OneSignal sendTags:@{@"key1": @"value1", @"key2": [OneSignal new]}];
1394+
[OneSignal sendTags:@{@"key1": @"value1", @"key2": [OneSignal new]} onSuccess:^(NSDictionary *result) {
1395+
XCTAssertNotNil(nil); //Assert if success is called
1396+
} onFailure:^(NSError *error) {
1397+
XCTAssertEqualObjects(error.domain, @"com.onesignal.tags");
1398+
[errorExpectation fulfill];
1399+
}];
13931400

13941401
// Make sure the tags were not sent.
13951402
[NSObjectOverrider runPendingSelectors];
13961403
[UnitTestCommonMethods runBackgroundThreads];
13971404
[NSObjectOverrider runPendingSelectors];
13981405

13991406
XCTAssertEqual(OneSignalClientOverrider.networkRequestCount, 2);
1407+
[self waitForExpectations:@[errorExpectation] timeout:1];
14001408
}
14011409

14021410
- (void)testDeleteTags {

0 commit comments

Comments
 (0)