@@ -3,68 +3,82 @@ import * as functions from 'firebase-functions';
33import { expectEq , TestSuite } from './testing' ;
44import UserMetadata = admin . auth . UserRecord ;
55
6- export const createUserTests : any = functions . auth . user ( ) . onCreate ( ( u , c ) => {
7- const testId : string = u . displayName ;
8- console . log ( `testId is ${ testId } ` ) ;
6+ const REGION = process . env . FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1' ;
97
10- return new TestSuite < UserMetadata > ( 'auth user onCreate' )
11- . it ( 'should have a project as resource' , ( user , context ) =>
12- expectEq ( context . resource . name , `projects/${ process . env . GCLOUD_PROJECT } ` )
13- )
8+ export const createUserTests : any = functions
9+ . region ( REGION )
10+ . auth . user ( )
11+ . onCreate ( ( u , c ) => {
12+ const testId : string = u . displayName ;
13+ console . log ( `testId is ${ testId } ` ) ;
1414
15- . it ( 'should not have a path' , ( user , context ) =>
16- expectEq ( ( context as any ) . path , undefined )
17- )
15+ return new TestSuite < UserMetadata > ( 'auth user onCreate' )
16+ . it ( 'should have a project as resource' , ( user , context ) =>
17+ expectEq (
18+ context . resource . name ,
19+ `projects/${ process . env . GCLOUD_PROJECT } `
20+ )
21+ )
1822
19- . it ( 'should have the correct eventType ' , ( user , context ) =>
20- expectEq ( context . eventType , 'google.firebase.auth.user.create' )
21- )
23+ . it ( 'should not have a path ' , ( user , context ) =>
24+ expectEq ( ( context as any ) . path , undefined )
25+ )
2226
23- . it ( 'should have an eventId' , ( user , context ) => context . eventId )
27+ . it ( 'should have the correct eventType' , ( user , context ) =>
28+ expectEq ( context . eventType , 'google.firebase.auth.user.create' )
29+ )
2430
25- . it ( 'should have a timestamp ' , ( user , context ) => context . timestamp )
31+ . it ( 'should have an eventId ' , ( user , context ) => context . eventId )
2632
27- . it ( 'should not have auth' , ( user , context ) =>
28- expectEq ( ( context as any ) . auth , undefined )
29- )
33+ . it ( 'should have a timestamp' , ( user , context ) => context . timestamp )
3034
31- . it ( 'should not have action ' , ( user , context ) =>
32- expectEq ( ( context as any ) . action , undefined )
33- )
35+ . it ( 'should not have auth ' , ( user , context ) =>
36+ expectEq ( ( context as any ) . auth , undefined )
37+ )
3438
35- . it ( 'should have properly defined meta' , ( user , context ) => user . metadata )
39+ . it ( 'should not have action' , ( user , context ) =>
40+ expectEq ( ( context as any ) . action , undefined )
41+ )
3642
37- . run ( testId , u , c ) ;
38- } ) ;
43+ . it ( 'should have properly defined meta' , ( user , context ) => user . metadata )
3944
40- export const deleteUserTests : any = functions . auth . user ( ) . onDelete ( ( u , c ) => {
41- const testId : string = u . displayName ;
42- console . log ( `testId is ${ testId } ` ) ;
45+ . run ( testId , u , c ) ;
46+ } ) ;
4347
44- return new TestSuite < UserMetadata > ( 'auth user onDelete' )
45- . it ( 'should have a project as resource' , ( user , context ) =>
46- expectEq ( context . resource . name , `projects/${ process . env . GCLOUD_PROJECT } ` )
47- )
48+ export const deleteUserTests : any = functions
49+ . region ( REGION )
50+ . auth . user ( )
51+ . onDelete ( ( u , c ) => {
52+ const testId : string = u . displayName ;
53+ console . log ( `testId is ${ testId } ` ) ;
4854
49- . it ( 'should not have a path' , ( user , context ) =>
50- expectEq ( ( context as any ) . path , undefined )
51- )
55+ return new TestSuite < UserMetadata > ( 'auth user onDelete' )
56+ . it ( 'should have a project as resource' , ( user , context ) =>
57+ expectEq (
58+ context . resource . name ,
59+ `projects/${ process . env . GCLOUD_PROJECT } `
60+ )
61+ )
5262
53- . it ( 'should have the correct eventType ' , ( user , context ) =>
54- expectEq ( context . eventType , 'google.firebase.auth.user.delete' )
55- )
63+ . it ( 'should not have a path ' , ( user , context ) =>
64+ expectEq ( ( context as any ) . path , undefined )
65+ )
5666
57- . it ( 'should have an eventId' , ( user , context ) => context . eventId )
67+ . it ( 'should have the correct eventType' , ( user , context ) =>
68+ expectEq ( context . eventType , 'google.firebase.auth.user.delete' )
69+ )
5870
59- . it ( 'should have a timestamp ' , ( user , context ) => context . timestamp )
71+ . it ( 'should have an eventId ' , ( user , context ) => context . eventId )
6072
61- . it ( 'should not have auth' , ( user , context ) =>
62- expectEq ( ( context as any ) . auth , undefined )
63- )
73+ . it ( 'should have a timestamp' , ( user , context ) => context . timestamp )
6474
65- . it ( 'should not have action ' , ( user , context ) =>
66- expectEq ( ( context as any ) . action , undefined )
67- )
75+ . it ( 'should not have auth ' , ( user , context ) =>
76+ expectEq ( ( context as any ) . auth , undefined )
77+ )
6878
69- . run ( testId , u , c ) ;
70- } ) ;
79+ . it ( 'should not have action' , ( user , context ) =>
80+ expectEq ( ( context as any ) . action , undefined )
81+ )
82+
83+ . run ( testId , u , c ) ;
84+ } ) ;
0 commit comments