aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Auth/Tests
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2017-11-17 15:55:56 -0800
committerGravatar GitHub <noreply@github.com>2017-11-17 15:55:56 -0800
commit5fbe71052de048a15f44476115a49e1958e70691 (patch)
treefead2d827d2264005dc82dd728b63a84f25dc156 /Example/Auth/Tests
parent4fbc96904fe86b3a0cdb91bfa6d96491221eb6b9 (diff)
Adds AuthDataResult to anonymous sign in (#470)
* Adds AuthDataResult to anonymous sign in * Fixes typo * Addresses comments * addresses comment on PR
Diffstat (limited to 'Example/Auth/Tests')
-rw-r--r--Example/Auth/Tests/FIRAuthTests.m57
1 files changed, 55 insertions, 2 deletions
diff --git a/Example/Auth/Tests/FIRAuthTests.m b/Example/Auth/Tests/FIRAuthTests.m
index d9a7461..557f0c7 100644
--- a/Example/Auth/Tests/FIRAuthTests.m
+++ b/Example/Auth/Tests/FIRAuthTests.m
@@ -1029,7 +1029,7 @@ static const NSTimeInterval kWaitInterval = .5;
}
/** @fn testSignInAnonymouslySuccess
- @brief Tests the flow of a successful @c signInAnonymously:completion: call.
+ @brief Tests the flow of a successful @c signInAnonymouslyWithCompletion: call.
*/
- (void)testSignInAnonymouslySuccess {
OCMExpect([_mockBackend signUpNewUser:[OCMArg any] callback:[OCMArg any]])
@@ -1061,7 +1061,7 @@ static const NSTimeInterval kWaitInterval = .5;
}
/** @fn testSignInAnonymouslyFailure
- @brief Tests the flow of a failed @c signInAnonymously:completion: call.
+ @brief Tests the flow of a failed @c signInAnonymouslyWithCompletion: call.
*/
- (void)testSignInAnonymouslyFailure {
OCMExpect([_mockBackend signUpNewUser:[OCMArg any] callback:[OCMArg any]])
@@ -1081,6 +1081,59 @@ static const NSTimeInterval kWaitInterval = .5;
OCMVerifyAll(_mockBackend);
}
+/** @fn testSignInAnonymouslyAndRetrieveDataSuccess
+ @brief Tests the flow of a successful @c signInAnonymouslyAndRetrieveDataWithCompletion: call.
+ */
+- (void)testSignInAnonymouslyAndRetrieveDataSuccess {
+ OCMExpect([_mockBackend signUpNewUser:[OCMArg any] callback:[OCMArg any]])
+ .andCallBlock2(^(FIRSignUpNewUserRequest *_Nullable request,
+ FIRSignupNewUserCallback callback) {
+ XCTAssertEqualObjects(request.APIKey, kAPIKey);
+ XCTAssertNil(request.email);
+ XCTAssertNil(request.password);
+ XCTAssertTrue(request.returnSecureToken);
+ dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
+ id mockSignUpNewUserResponse = OCMClassMock([FIRSignUpNewUserResponse class]);
+ [self stubTokensWithMockResponse:mockSignUpNewUserResponse];
+ callback(mockSignUpNewUserResponse, nil);
+ });
+ });
+ [self expectGetAccountInfoAnonymous];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
+ [[FIRAuth auth] signOut:NULL];
+ [[FIRAuth auth] signInAnonymouslyAndRetrieveDataWithCompletion:
+ ^(FIRAuthDataResult *_Nullable result, NSError *_Nullable error) {
+ XCTAssertTrue([NSThread isMainThread]);
+ [self assertUserAnonymous:result.user];
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];
+ [self assertUserAnonymous:[FIRAuth auth].currentUser];
+ OCMVerifyAll(_mockBackend);
+}
+
+/** @fn testSignInAnonymouslyAndRetrieveDataFailure
+ @brief Tests the flow of a failed @c signInAnonymouslyAndRetrieveDataWithCompletion: call.
+ */
+- (void)testSignInAnonymouslyAndRetrieveDataFailure {
+ OCMExpect([_mockBackend signUpNewUser:[OCMArg any] callback:[OCMArg any]])
+ .andDispatchError2([FIRAuthErrorUtils operationNotAllowedErrorWithMessage:nil]);
+ XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
+ [[FIRAuth auth] signOut:NULL];
+ [[FIRAuth auth] signInAnonymouslyAndRetrieveDataWithCompletion:
+ ^(FIRAuthDataResult *_Nullable result, NSError *_Nullable error) {
+ XCTAssertTrue([NSThread isMainThread]);
+ XCTAssertNil(result);
+ XCTAssertEqual(error.code, FIRAuthErrorCodeOperationNotAllowed);
+ XCTAssertNotNil(error.userInfo[NSLocalizedDescriptionKey]);
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];
+ XCTAssertNil([FIRAuth auth].currentUser);
+ OCMVerifyAll(_mockBackend);
+}
+
/** @fn testSignInWithCustomTokenSuccess
@brief Tests the flow of a successful @c signInWithCustomToken:completion: call.
*/