Skip to content

Commit 6c56c98

Browse files
add test for an error case
1 parent 4f19636 commit 6c56c98

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

packages/auth/test/auth_test.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ function testAuth_onAuthStateChanged() {
16611661
* Test whether we can retrieve the signed-in user as a promise.
16621662
* We also verify the behavior when user signs out.
16631663
*/
1664-
function testAuth_getSignedInUser() {
1664+
function testAuth_getSignedInUser_success() {
16651665
stubs.reset();
16661666
var expectedTokenResponse2 = {
16671667
'idToken': jwt2,
@@ -1748,6 +1748,30 @@ function testAuth_getSignedInUser() {
17481748
asyncTestCase.waitForSignals(1);
17491749
}
17501750

1751+
function testAuth_getSignedInUser_error() {
1752+
stubs.reset();
1753+
var expectedError = new fireauth.AuthError(
1754+
fireauth.authenum.Error.INTERNAL_ERROR);
1755+
// throw when onAuthStateChanged is called
1756+
stubs.replace(
1757+
fireauth.Auth.prototype,
1758+
'onAuthStateChanged',
1759+
function(tokenResponse) {
1760+
throw expectedError;
1761+
});
1762+
app1 = firebase.initializeApp(config1, appId1);
1763+
auth1 = app1.auth();
1764+
auth1.getSignedInUser()
1765+
.then((signedInUser) => {
1766+
fail('getSignedInUser should not resolve!');
1767+
})
1768+
.catch(function(error) {
1769+
fireauth.common.testHelper.assertErrorEquals(expectedError, error);
1770+
asyncTestCase.signal();
1771+
});
1772+
mockControl.$replayAll();
1773+
asyncTestCase.waitForSignals(1);
1774+
}
17511775

17521776
function testFetchSignInMethodsForEmail() {
17531777
var email = '[email protected]';

0 commit comments

Comments
 (0)