11import {
22 authDataToAuthState ,
33 AuthProviders ,
4- FirebaseAuthState ,
5- CommonOAuthCredential ,
6- GoogleCredential ,
7- TwitterCredential
4+ FirebaseAuthState
85} from './auth_backend' ;
96
107const baseFBUser = {
@@ -25,94 +22,93 @@ const baseAuthState: FirebaseAuthState = {
2522 auth : < firebase . User > baseFBUser
2623} ;
2724
28- const baseGithubCredential : CommonOAuthCredential = {
29- accessToken : 'GH_ACCESS_TOKEN ' ,
30- provider : 'github.com '
31- } ;
25+ const baseGithubCredential = {
26+ providerId : 'github.com ' ,
27+ displayName : 'GithubAlice '
28+ } as firebase . UserInfo ;
3229
33- const baseFacebookCredential : CommonOAuthCredential = {
34- accessToken : 'FB_ACCESS_TOKEN ' ,
35- provider : 'facebook.com'
36- } ;
30+ const baseFacebookCredential = {
31+ displayName : 'FacebookFranny ' ,
32+ providerId : 'facebook.com'
33+ } as firebase . UserInfo ;
3734
38- const baseGoogleCredential : GoogleCredential = {
39- idToken : 'GOOGLE_ID_TOKEN ' ,
40- provider : 'google.com'
41- } ;
35+ const baseGoogleCredential = {
36+ displayName : 'GoogleGerry ' ,
37+ providerId : 'google.com'
38+ } as firebase . UserInfo ;
4239
43- const baseTwitterCredential : TwitterCredential = {
44- accessToken : 'TWITTER_ACCESS_TOKEN' ,
45- provider : 'twitter.com' ,
46- secret : 'TWITTER_SECRET'
47- } ;
40+ const baseTwitterCredential = {
41+ displayName : 'TwitterTiffany' ,
42+ providerId : 'twitter.com' ,
43+ } as firebase . UserInfo ;
4844
4945describe ( 'auth_backend' , ( ) => {
5046 describe ( 'authDataToAuthState' , ( ) => {
5147 it ( 'Github: should return a FirebaseAuthState object with full provider data' , ( ) => {
5248 let githubUser = Object . assign ( { } , baseFBUser , {
5349 providerData : [ { providerId : 'github.com' } ]
54- } ) ;
50+ } ) as firebase . User ;
5551 let expectedAuthState = Object . assign ( { } , baseAuthState , {
5652 github : baseGithubCredential ,
5753 auth : githubUser
5854 } ) ;
5955
6056 let actualAuthState = authDataToAuthState ( githubUser , baseGithubCredential ) ;
61- expect ( actualAuthState . github . accessToken ) . toEqual ( baseGithubCredential . accessToken ) ;
57+ expect ( actualAuthState . github . displayName ) . toEqual ( baseGithubCredential . displayName ) ;
6258 } ) ;
6359 } ) ;
6460
6561 it ( 'Google: should return a FirebaseAuthState object with full provider data' , ( ) => {
6662 let googleUser = Object . assign ( { } , baseFBUser , {
6763 providerData : [ { providerId : 'google.com' } ]
68- } ) ;
64+ } ) as firebase . User ;
6965 let expectedAuthState = Object . assign ( { } , baseAuthState , {
7066 google : baseGoogleCredential ,
7167 auth : googleUser
7268 } ) ;
7369
7470 let actualAuthState = authDataToAuthState ( googleUser , baseGoogleCredential ) ;
75- expect ( actualAuthState . google . idToken ) . toEqual ( baseGoogleCredential . idToken ) ;
71+ expect ( actualAuthState . google . displayName ) . toEqual ( baseGoogleCredential . displayName ) ;
7672 } ) ;
7773
7874 it ( 'Twitter: should return a FirebaseAuthState object with full provider data' , ( ) => {
7975 let twitterUser = Object . assign ( { } , baseFBUser , {
8076 providerData : [ { providerId : 'twitter.com' } ]
81- } ) ;
77+ } ) as firebase . User ;
8278 let expectedAuthState = Object . assign ( { } , baseAuthState , {
8379 twitter : baseTwitterCredential ,
8480 auth : twitterUser
8581 } ) ;
8682
8783 let actualAuthState = authDataToAuthState ( twitterUser , baseTwitterCredential ) ;
88- expect ( actualAuthState . twitter . secret ) . toEqual ( baseTwitterCredential . secret ) ;
84+ expect ( actualAuthState . twitter . displayName ) . toEqual ( baseTwitterCredential . displayName ) ;
8985 } ) ;
9086
9187 it ( 'Facebook: should return a FirebaseAuthState object with full provider data' , ( ) => {
9288 let facebookUser = Object . assign ( { } , baseFBUser , {
9389 providerData : [ { providerId : 'facebook.com' } ]
94- } ) ;
90+ } ) as firebase . User ;
9591 let expectedAuthState = Object . assign ( { } , baseAuthState , {
9692 facebook : baseFacebookCredential ,
9793 auth : facebookUser
9894 } ) ;
9995
10096 let actualAuthState = authDataToAuthState ( facebookUser , baseFacebookCredential ) ;
101- expect ( actualAuthState . facebook . accessToken ) . toEqual ( baseFacebookCredential . accessToken ) ;
97+ expect ( actualAuthState . facebook . displayName ) . toEqual ( baseFacebookCredential . displayName ) ;
10298 } ) ;
10399
104100
105101 it ( 'Anonymous: should return a FirebaseAuthState object' , ( ) => {
106- let anonymouseFirebaseUser = Object . assign ( { } , baseFBUser , {
102+ let anonymousFirebaseUser = Object . assign ( { } , baseFBUser , {
107103 providerData : [ ] ,
108104 isAnonymous : true
109- } ) ;
105+ } ) as firebase . User ;
110106 let expectedAuthState = Object . assign ( { } , baseAuthState , {
111107 facebook : baseFacebookCredential ,
112- auth : anonymouseFirebaseUser
108+ auth : anonymousFirebaseUser
113109 } ) ;
114110
115- let actualAuthState = authDataToAuthState ( anonymouseFirebaseUser ) ;
111+ let actualAuthState = authDataToAuthState ( anonymousFirebaseUser ) ;
116112 expect ( actualAuthState . anonymous ) . toEqual ( true ) ;
117113 } ) ;
118114} ) ;
0 commit comments