Skip to content

Commit 5248fc6

Browse files
committed
fix auth test
1 parent 7eb4ea6 commit 5248fc6

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

packages/auth/test/auth_test.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,17 +1014,18 @@ function testGetUid_userSignedIn() {
10141014
// Initialize App and Auth.
10151015
app1 = firebase.initializeApp(config1, appId1);
10161016
auth1 = app1.auth();
1017+
var authInternal1 = app1.container.getProvider('auth-internal').getImmediate();
10171018
// Initially getUid() should return null;
10181019
assertNull(auth1.getUid());
1019-
assertNull(app1.INTERNAL.getUid());
1020+
assertNull(authInternal1.getUid());
10201021
// Listen to Auth changes.
10211022
var unsubscribe = auth1.onIdTokenChanged(function(currentUser) {
10221023
// Unsubscribe of Auth state change listener.
10231024
unsubscribe();
10241025
// Logged in test user should be detected.
10251026
// Confirm getUid() returns expected UID.
10261027
assertEquals(accountInfo1['uid'], auth1.getUid());
1027-
assertEquals(accountInfo1['uid'], app1.INTERNAL.getUid());
1028+
assertEquals(accountInfo1['uid'], authInternal1.getUid());
10281029
goog.Timer.promise(10).then(function() {
10291030
// Sign out.
10301031
return auth1.signOut();
@@ -1033,7 +1034,7 @@ function testGetUid_userSignedIn() {
10331034
}).then(function() {
10341035
// getUid() should return null.
10351036
assertNull(auth1.getUid());
1036-
assertNull(app1.INTERNAL.getUid());
1037+
assertNull(authInternal1.getUid());
10371038
asyncTestCase.signal();
10381039
});
10391040
});
@@ -1065,19 +1066,20 @@ function testGetUid_noUserSignedIn() {
10651066
// Initialize App and Auth.
10661067
app1 = firebase.initializeApp(config1, appId1);
10671068
auth1 = app1.auth();
1069+
var authInternal1 = app1.container.getProvider('auth-internal').getImmediate();
10681070
// Listen to Auth changes.
10691071
var unsubscribe = auth1.onIdTokenChanged(function(currentUser) {
10701072
// Unsubscribe of Auth state change listener.
10711073
unsubscribe();
10721074
// Initially getUid() should return null;
10731075
assertNull(auth1.getUid());
1074-
assertNull(app1.INTERNAL.getUid());
1076+
assertNull(authInternal1.getUid());
10751077
// Sign in with email and password.
10761078
auth1.signInWithEmailAndPassword('[email protected]', 'password')
10771079
.then(function(userCredential) {
10781080
// getUid() should return the test user UID.
10791081
assertEquals(accountInfo1['uid'], auth1.getUid());
1080-
assertEquals(accountInfo1['uid'], app1.INTERNAL.getUid());
1082+
assertEquals(accountInfo1['uid'], authInternal1.getUid());
10811083
asyncTestCase.signal();
10821084
});
10831085
});
@@ -1118,11 +1120,13 @@ function testNotifyAuthListeners() {
11181120
config1['apiKey'] + ':' + appId1);
11191121
currentUserStorageManager.setCurrentUser(user).then(function() {
11201122
app1 = firebase.initializeApp(config1, appId1);
1121-
app1.INTERNAL.addAuthTokenListener(app1AuthTokenListener);
11221123
auth1 = app1.auth();
1124+
var authInternal1 = app1.container.getProvider('auth-internal').getImmediate();
1125+
authInternal1.addAuthTokenListener(app1AuthTokenListener);
11231126
app2 = firebase.initializeApp(config2, appId2);
1124-
app2.INTERNAL.addAuthTokenListener(app2AuthTokenListener);
11251127
auth2 = app2.auth();
1128+
var authInternal2 = app2.container.getProvider('auth-internal').getImmediate();
1129+
authInternal2.addAuthTokenListener(app2AuthTokenListener);
11261130
// Confirm all listeners reset.
11271131
assertEquals(0, listener1.getCallCount());
11281132
assertEquals(0, listener2.getCallCount());
@@ -1134,6 +1138,7 @@ function testNotifyAuthListeners() {
11341138
auth2.addAuthTokenListener(listener3);
11351139
// Wait for state to be ready on auth1.
11361140
var unsubscribe = auth1.onIdTokenChanged(function(currentUser) {
1141+
console.log('auth1 llllllll', currentUser);
11371142
unsubscribe();
11381143
// Listener 1 and 2 triggered.
11391144
assertEquals(1, listener1.getCallCount());
@@ -1170,7 +1175,7 @@ function testNotifyAuthListeners() {
11701175
app1AuthTokenListener.reset();
11711176
listener2.reset();
11721177
auth1.removeAuthTokenListener(listener2);
1173-
app1.INTERNAL.removeAuthTokenListener(app1AuthTokenListener);
1178+
authInternal1.removeAuthTokenListener(app1AuthTokenListener);
11741179
// Force token change.
11751180
currentAccessToken = 'accessToken3';
11761181
auth1['currentUser'].getIdToken().then(function(token) {
@@ -1185,6 +1190,7 @@ function testNotifyAuthListeners() {
11851190
});
11861191
// Wait for state to be ready on auth2.
11871192
auth2.onIdTokenChanged(function(currentUser) {
1193+
console.log('auth222222', currentUser);
11881194
// auth2 listener triggered on init with null state once.
11891195
assertEquals(1, listener3.getCallCount());
11901196
assertEquals(
@@ -10077,7 +10083,7 @@ function testAuth_proactiveTokenRefresh_multipleUsers() {
1007710083
auth1 = app1.auth();
1007810084
var subscriber = function(token) {};
1007910085
// Simulate Firebase service added.
10080-
app1.INTERNAL.addAuthTokenListener(subscriber);
10086+
app1.container.getProvider('auth-internal').getImmediate().addAuthTokenListener(subscriber);
1008110087
// Simulate user1 signed in.
1008210088
auth1.signInWithIdTokenResponse(expectedTokenResponse).then(function() {
1008310089
// Current user should be set to user1.
@@ -10155,7 +10161,7 @@ function testAuth_proactiveTokenRefresh_firebaseServiceAddedAfterSignIn() {
1015510161
assertEquals(
1015610162
0, fireauth.AuthUser.prototype.startProactiveRefresh.getCallCount());
1015710163
// Simulate Firebase service added.
10158-
app1.INTERNAL.addAuthTokenListener(subscriber);
10164+
app1.container.getProvider('auth-internal').getImmediate().addAuthTokenListener(subscriber);
1015910165
// Confirm proactive refresh started on that user.
1016010166
assertEquals(
1016110167
1, fireauth.AuthUser.prototype.startProactiveRefresh.getCallCount());
@@ -10199,10 +10205,11 @@ function testAuth_proactiveTokenRefresh_firebaseServiceRemovedAfterSignIn() {
1019910205
auth1 = app1.auth();
1020010206
var subscriber = function(token) {};
1020110207
// Simulate Firebase service added.
10202-
app1.INTERNAL.addAuthTokenListener(subscriber);
10208+
var authInternal = app1.container.getProvider('auth-internal').getImmediate();
10209+
authInternal.addAuthTokenListener(subscriber);
1020310210
// Add same listener again to check that removing it once will ensure the
1020410211
// proactive refresh is stopped.
10205-
app1.INTERNAL.addAuthTokenListener(subscriber);
10212+
authInternal.addAuthTokenListener(subscriber);
1020610213
// Simulate user signed in.
1020710214
auth1.signInWithIdTokenResponse(expectedTokenResponse).then(function() {
1020810215
// Current user should be set to user1.
@@ -10214,7 +10221,7 @@ function testAuth_proactiveTokenRefresh_firebaseServiceRemovedAfterSignIn() {
1021410221
assertEquals(
1021510222
0, fireauth.AuthUser.prototype.stopProactiveRefresh.getCallCount());
1021610223
// Simulate Firebase service removed.
10217-
app1.INTERNAL.removeAuthTokenListener(subscriber);
10224+
authInternal.removeAuthTokenListener(subscriber);
1021810225
// Confirm proactive refresh stopped on that user.
1021910226
assertEquals(
1022010227
1, fireauth.AuthUser.prototype.stopProactiveRefresh.getCallCount());

0 commit comments

Comments
 (0)