@@ -52,42 +52,52 @@ const reportResponse = {
52
52
media : { } ,
53
53
} ;
54
54
55
+ const response = {
56
+ subject_id : 'some-subject' ,
57
+ result : 'DONE' ,
58
+ failure_reason : {
59
+ reason_code : 'MANDATORY_DOCUMENT_NOT_PROVIDED' ,
60
+ requirements_not_met_details : [
61
+ {
62
+ failure_type : 'ID_DOCUMENT_EXTRACTION' ,
63
+ document_type : 'PASSPORT' ,
64
+ document_country_iso_code : 'GBR' ,
65
+ audit_id : 'audit-123' ,
66
+ details : 'something not right' ,
67
+ } ,
68
+ {
69
+ failure_type : 'ID_DOCUMENT_AUTHENTICITY' ,
70
+ document_type : 'PASSPORT' ,
71
+ document_country_iso_code : 'GBR' ,
72
+ audit_id : 'audit-456' ,
73
+ details : 'something still not right' ,
74
+ } ,
75
+ ] ,
76
+ } ,
77
+ identity_profile_report : reportResponse ,
78
+ } ;
79
+
55
80
describe ( 'AdvancedIdentityProfileResponse' , ( ) => {
56
81
let advancedIdentityProfileResponse ;
57
82
58
83
beforeEach ( ( ) => {
59
- const response = {
60
- subject_id : 'some-subject' ,
61
- result : 'DONE' ,
62
- failure_reason : {
63
- reason_code : 'MANDATORY_DOCUMENT_NOT_PROVIDED' ,
64
- requirements_not_met_details : [
65
- {
66
- failure_type : 'ID_DOCUMENT_EXTRACTION' ,
67
- document_type : 'PASSPORT' ,
68
- document_country_iso_code : 'GBR' ,
69
- audit_id : 'audit-123' ,
70
- details : 'something not right' ,
71
- } ,
72
- {
73
- failure_type : 'ID_DOCUMENT_AUTHENTICITY' ,
74
- document_type : 'PASSPORT' ,
75
- document_country_iso_code : 'GBR' ,
76
- audit_id : 'audit-456' ,
77
- details : 'something still not right' ,
78
- } ,
79
- ] ,
80
- } ,
81
- identity_profile_report : reportResponse ,
82
- } ;
83
-
84
84
advancedIdentityProfileResponse = new AdvancedIdentityProfileResponse ( response ) ;
85
85
} ) ;
86
86
87
87
describe ( '#getSubjectId' , ( ) => {
88
88
it ( 'Should return ID' , ( ) => {
89
89
expect ( advancedIdentityProfileResponse . getSubjectId ( ) ) . toBe ( 'some-subject' ) ;
90
90
} ) ;
91
+
92
+ describe ( 'with a non existing "subject_id"' , ( ) => {
93
+ it ( 'should still parse the response and return empty string for #getSubjectId' , ( ) => {
94
+ const responseWithoutSubjectId = { ...response } ;
95
+ delete responseWithoutSubjectId . subject_id ;
96
+ // eslint-disable-next-line max-len
97
+ advancedIdentityProfileResponse = new AdvancedIdentityProfileResponse ( responseWithoutSubjectId ) ;
98
+ expect ( advancedIdentityProfileResponse . getSubjectId ( ) ) . toBe ( '' ) ;
99
+ } ) ;
100
+ } ) ;
91
101
} ) ;
92
102
93
103
describe ( '#getResult' , ( ) => {
0 commit comments