@@ -20,6 +20,7 @@ import * as sinon from 'sinon';
20
20
import * as sinonChai from 'sinon-chai' ;
21
21
22
22
import { FirebaseApp } from '@firebase/app-types-exp' ;
23
+ import * as externs from '@firebase/auth-types-exp' ;
23
24
import { FirebaseError } from '@firebase/util' ;
24
25
25
26
import { testUser } from '../../../test/mock_auth' ;
@@ -31,10 +32,7 @@ import { inMemoryPersistence } from '../persistence/in_memory';
31
32
import { PersistenceUserManager } from '../persistence/persistence_user_manager' ;
32
33
import { _getClientVersion , ClientPlatform } from '../util/version' ;
33
34
import {
34
- DEFAULT_API_HOST ,
35
- DEFAULT_API_SCHEME ,
36
- DEFAULT_TOKEN_API_HOST ,
37
- initializeAuth
35
+ DEFAULT_API_HOST , DEFAULT_API_SCHEME , DEFAULT_TOKEN_API_HOST , initializeAuth
38
36
} from './auth_impl' ;
39
37
40
38
use ( sinonChai ) ;
@@ -53,8 +51,8 @@ describe('core/auth/auth_impl', () => {
53
51
let persistenceStub : sinon . SinonStubbedInstance < Persistence > ;
54
52
55
53
beforeEach ( ( ) => {
56
- persistenceStub = sinon . stub ( inMemoryPersistence ) ;
57
- auth = initializeAuth ( FAKE_APP , { persistence : inMemoryPersistence } ) ;
54
+ persistenceStub = sinon . stub ( inMemoryPersistence as Persistence ) ;
55
+ auth = initializeAuth ( FAKE_APP , { persistence : inMemoryPersistence } ) as Auth ;
58
56
} ) ;
59
57
60
58
afterEach ( sinon . restore ) ;
@@ -104,7 +102,7 @@ describe('core/auth/auth_impl', () => {
104
102
105
103
describe ( '#setPersistence' , ( ) => {
106
104
it ( 'swaps underlying persistence' , async ( ) => {
107
- const newPersistence = browserLocalPersistence ;
105
+ const newPersistence = browserLocalPersistence as Persistence ;
108
106
const newStub = sinon . stub ( newPersistence ) ;
109
107
persistenceStub . get . returns (
110
108
Promise . resolve ( testUser ( 'test' ) . toPlainObject ( ) )
@@ -271,18 +269,20 @@ describe('core/auth/initializeAuth', () => {
271
269
272
270
describe ( 'persistence manager creation' , ( ) => {
273
271
let createManagerStub : sinon . SinonSpy ;
272
+ // const inMemory = inMemoryPersistence as Persistence;
273
+ // const browserLocal = browserL
274
274
beforeEach ( ( ) => {
275
275
createManagerStub = sinon . spy ( PersistenceUserManager , 'create' ) ;
276
276
} ) ;
277
277
278
278
async function initAndWait (
279
- persistence : Persistence | Persistence [ ]
279
+ persistence : externs . Persistence | externs . Persistence [ ]
280
280
) : Promise < Auth > {
281
281
const auth = initializeAuth ( FAKE_APP , { persistence } ) ;
282
282
// Auth initializes async. We can make sure the initialization is
283
283
// flushed by awaiting a method on the queue.
284
284
await auth . setPersistence ( inMemoryPersistence ) ;
285
- return auth ;
285
+ return auth as Auth ;
286
286
}
287
287
288
288
it ( 'converts single persistence to array' , async ( ) => {
@@ -294,7 +294,7 @@ describe('core/auth/initializeAuth', () => {
294
294
295
295
it ( 'pulls the user from storage' , async ( ) => {
296
296
sinon
297
- . stub ( inMemoryPersistence , 'get' )
297
+ . stub ( inMemoryPersistence as Persistence , 'get' )
298
298
. returns ( Promise . resolve ( testUser ( 'uid' ) . toPlainObject ( ) ) ) ;
299
299
const auth = await initAndWait ( inMemoryPersistence ) ;
300
300
expect ( auth . currentUser ! . uid ) . to . eq ( 'uid' ) ;
0 commit comments