Skip to content

Commit bf85342

Browse files
committed
[Functions] 'call' API should reenter on main thread
1 parent 5003be4 commit bf85342

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

FirebaseFunctions/Tests/ObjCIntegration/FIRIntegrationTests.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,28 @@ - (void)testTimeout {
290290
[self waitForExpectations:@[ expectation ] timeout:10];
291291
}
292292

293+
- (void)testFunctionsReturnsOnMainThread {
294+
XCTestExpectation *expectation = [[XCTestExpectation alloc] init];
295+
FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"scalarTest"];
296+
[function callWithObject:@17
297+
completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
298+
XCTAssert(NSThread.isMainThread);
299+
XCTAssertNotNil(result);
300+
[expectation fulfill];
301+
}];
302+
[self waitForExpectations:@[ expectation ] timeout:10];
303+
}
304+
305+
- (void)testFunctionErrorsOnMainThread {
306+
XCTestExpectation *expectation = [[XCTestExpectation alloc] init];
307+
FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"httpErrorTest"];
308+
[function callWithObject:@{}
309+
completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
310+
XCTAssert(NSThread.isMainThread);
311+
XCTAssertNotNil(error);
312+
[expectation fulfill];
313+
}];
314+
[self waitForExpectations:@[ expectation ] timeout:10];
315+
}
316+
293317
@end

0 commit comments

Comments
 (0)