1- import { admin , test } from '../../util/admin ' ;
1+ import { admin , test } from '../../util/config ' ;
22import * as chai from 'chai' ;
3- import * as onUpdate from '../../../src/db/users/onUpdate.function' ;
3+ import onUpdate from '../../../src/db/users/onUpdate.function' ;
44import 'mocha' ;
55
66describe ( 'onUpdate' , ( ) => {
77 let userRecord : any ;
88
99 before ( async ( ) => {
1010 const user = {
11- uid : '1234' ,
1211 email : 'user@example.com' ,
1312 password : 'secretPassword'
1413 } ;
@@ -25,8 +24,8 @@ describe('onUpdate', () => {
2524 test . cleanup ( ) ;
2625 } ) ;
2726
28- it ( ' should update the user information in the database' , ( ) => {
29- const wrapped = test . wrap ( onUpdate . default ) ;
27+ it ( " should update user's custom claims in auth" , async ( ) => {
28+ const wrapped = test . wrap ( onUpdate ) ;
3029
3130 const beforeSnap = test . database . makeDataSnapshot (
3231 { email : 'user@example.com' , isAdmin : false } ,
@@ -39,17 +38,16 @@ describe('onUpdate', () => {
3938
4039 const change = test . makeChange ( beforeSnap , afterSnap ) ;
4140
42- return wrapped ( change , {
41+ await wrapped ( change , {
4342 params : {
4443 uid : userRecord . uid
4544 }
46- } ) . then ( ( ) => {
47- return admin
48- . auth ( )
49- . getUser ( userRecord . uid )
50- . then ( snap => {
51- chai . assert . isTrue ( snap . customClaims ! . isAdmin ) ;
52- } ) ;
5345 } ) ;
46+ return admin
47+ . auth ( )
48+ . getUser ( userRecord . uid )
49+ . then ( snap => {
50+ chai . assert . isTrue ( snap . customClaims ! . isAdmin ) ;
51+ } ) ;
5452 } ) ;
5553} ) ;
0 commit comments