11import UserData from '../lib/user-data' ;
2+ import { IdentityVerification } from '../lib/index' ;
23import assert from 'assert' ;
34import sinon from 'sinon' ;
45
@@ -21,7 +22,13 @@ describe('userData', () => {
21222223 } ;
2324 const userData = new UserData ( settings ) ;
24- assert . equal ( userData . getIdentifier ( ) , 1 ) ;
25+ const userHash = sinon . spy ( IdentityVerification , 'userHash' ) ;
26+ userData . json ( ) ;
27+ userHash . restore ( ) ;
28+ sinon . assert . calledWith ( userHash , {
29+ secretKey : 'abc123' ,
30+ identifier : '1'
31+ } ) ;
2532 } ) ;
2633
2734 it ( 'should grab the email as the identifier if no user_id' , ( ) => {
@@ -31,7 +38,13 @@ describe('userData', () => {
31383239 } ;
3340 const userData = new UserData ( settings ) ;
34- assert . equal ( userData . getIdentifier ( ) , '[email protected] ' ) ; 41+ const userHash = sinon . spy ( IdentityVerification , 'userHash' ) ;
42+ userData . json ( ) ;
43+ userHash . restore ( ) ;
44+ sinon . assert . calledWith ( userHash , {
45+ secretKey : 'abc123' ,
46+ 47+ } ) ;
3548 } ) ;
3649
3750 it ( 'should throw an error if there\'s no verification secret' , ( ) => {
@@ -118,11 +131,11 @@ describe('userData', () => {
118131 user_id : 1
119132 } ;
120133 const userData = new UserData ( settings ) ;
121- const setUserHash = sinon . spy ( userData , 'setUserHash ' ) ;
134+ const userHash = sinon . spy ( IdentityVerification , 'userHash ' ) ;
122135 userData . json ( ) ;
123136 userData . json ( ) ;
124- setUserHash . restore ( ) ;
125- sinon . assert . calledOnce ( setUserHash ) ;
137+ userHash . restore ( ) ;
138+ sinon . assert . calledOnce ( userHash ) ;
126139 } ) ;
127140
128141 it ( 'should return the userData' , ( ) => {
0 commit comments