@@ -21,7 +21,7 @@ import * as chaiAsPromised from 'chai-as-promised';
21
21
22
22
import { deepCopy } from '../../../src/utils/deep-copy' ;
23
23
import {
24
- GetAccountInfoUserResponse , ProviderUserInfoResponse , MultiFactorInfoResponse , TotpMultiFactorInfo ,
24
+ GetAccountInfoUserResponse , ProviderUserInfoResponse , MultiFactorInfoResponse , TotpMultiFactorInfo , PasskeyInfo ,
25
25
} from '../../../src/auth/user-record' ;
26
26
import {
27
27
UserInfo , UserMetadata , UserRecord , MultiFactorSettings , MultiFactorInfo , PhoneMultiFactorInfo ,
@@ -100,6 +100,18 @@ function getValidUserResponse(tenantId?: string): GetAccountInfoUserResponse {
100
100
phoneInfo : '+16505556789' ,
101
101
} ,
102
102
] ,
103
+ passkeyInfo : [
104
+ {
105
+
106
+ credentialId : "credentialId1" ,
107
+ displayName : "passkey1" ,
108
+ } ,
109
+ {
110
+
111
+ credentialId : "credentialId2" ,
112
+ displayName : "passkey2" ,
113
+ }
114
+ ]
103
115
} ;
104
116
if ( typeof tenantId !== 'undefined' ) {
105
117
response . tenantId = tenantId ;
@@ -185,6 +197,18 @@ function getUserJSON(tenantId?: string): object {
185
197
} ,
186
198
] ,
187
199
} ,
200
+ passkeyInfo : [
201
+ {
202
+
203
+ credentialId : "credentialId1" ,
204
+ displayName : "passkey1" ,
205
+ } ,
206
+ {
207
+
208
+ credentialId : "credentialId2" ,
209
+ displayName : "passkey2" ,
210
+ }
211
+ ]
188
212
} ;
189
213
}
190
214
@@ -663,6 +687,66 @@ describe('MultiFactorSettings', () => {
663
687
} ) ;
664
688
} ) ;
665
689
690
+ describe ( 'PasskeyInfo' , ( ) => {
691
+ const passkeyInfoData = {
692
+ name : 'John Doe' ,
693
+ credentialId : 'credential123' ,
694
+
695
+ } ;
696
+ const passkeyInfo = new PasskeyInfo ( passkeyInfoData ) ;
697
+
698
+ describe ( 'constructor' , ( ) => {
699
+ it ( 'should create a PasskeyInfo object with valid data' , ( ) => {
700
+ expect ( passkeyInfo ) . to . be . an . instanceOf ( PasskeyInfo ) ;
701
+ } ) ;
702
+
703
+ it ( 'should throw when missing required fields' , ( ) => {
704
+ expect ( ( ) => {
705
+ return new PasskeyInfo ( { } ) ;
706
+ } ) . to . throw ( 'INTERNAL ASSERT FAILED: Invalid passkey info response' ) ;
707
+ } ) ;
708
+ } ) ;
709
+
710
+ describe ( 'getters' , ( ) => {
711
+ it ( 'should return the expected name' , ( ) => {
712
+ expect ( passkeyInfo . name ) . to . equal ( passkeyInfoData . name ) ;
713
+ } ) ;
714
+
715
+ it ( 'should throw when modifying readonly name property' , ( ) => {
716
+ expect ( ( ) => {
717
+ ( passkeyInfo as any ) . name = 'Modified Name' ;
718
+ } ) . to . throw ( Error ) ;
719
+ } ) ;
720
+
721
+ it ( 'should return the expected credentialId' , ( ) => {
722
+ expect ( passkeyInfo . credentialId ) . to . equal ( passkeyInfoData . credentialId ) ;
723
+ } ) ;
724
+
725
+ it ( 'should throw when modifying readonly credentialId property' , ( ) => {
726
+ expect ( ( ) => {
727
+ ( passkeyInfo as any ) . credentialId = 'modifiedCredential' ;
728
+ } ) . to . throw ( Error ) ;
729
+ } ) ;
730
+
731
+ it ( 'should return the expected displayName' , ( ) => {
732
+ expect ( passkeyInfo . displayName ) . to . equal ( passkeyInfoData . displayName ) ;
733
+ } ) ;
734
+
735
+ it ( 'should throw when modifying readonly displayName property' , ( ) => {
736
+ expect ( ( ) => {
737
+ ( passkeyInfo as any ) . displayName = 'modifiedDisplayName' ;
738
+ } ) . to . throw ( Error ) ;
739
+ } ) ;
740
+ } ) ;
741
+
742
+ describe ( 'toJSON' , ( ) => {
743
+ it ( 'should return the expected JSON object' , ( ) => {
744
+ expect ( passkeyInfo . toJSON ( ) ) . to . deep . equal ( passkeyInfoData ) ;
745
+ } ) ;
746
+ } ) ;
747
+ } ) ;
748
+
749
+
666
750
describe ( 'UserInfo' , ( ) => {
667
751
describe ( 'constructor' , ( ) => {
668
752
it ( 'should throw when an empty object is provided' , ( ) => {
0 commit comments