File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed
packages/mobile-sdk-alpha/tests/stores Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,12 @@ const fetchTree = async (url: string): Promise<any> => {
1414 throw new Error ( `HTTP error fetching ${ url } ! status: ${ res . status } ` ) ;
1515 }
1616 const responseData = await res . json ( ) ;
17- // Accept either wrapped { status: 'success', data: ... } or raw payloads
18- if ( responseData && typeof responseData === 'object' ) {
19- if ( 'status' in responseData || 'data' in responseData ) {
20- if ( responseData . status !== 'success' || ! responseData . data ) {
21- throw new Error (
22- `Failed to fetch tree from ${ url } : ${ responseData . message || 'Invalid response format' } `
23- ) ;
24- }
25- return responseData . data ;
26- }
27- // Raw tree payload (already the tree)
28- return responseData ;
17+ if ( responseData . status !== 'success' || ! responseData . data ) {
18+ throw new Error (
19+ `Failed to fetch tree from ${ url } : ${ responseData . message || 'Invalid response format' } `
20+ ) ;
2921 }
30- throw new Error ( `Failed to fetch tree from ${ url } : Unexpected response type` ) ;
22+ return responseData . data ;
3123} ;
3224
3325// Main public helper that retrieves the three OFAC trees depending on the variant (passport vs id_card).
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ describe('protocolStore.fetch_ofac_trees', () => {
3131 'name-yob' : { root : [ 'yob' ] } ,
3232 } ;
3333
34- vi . spyOn ( global , 'fetch' ) . mockImplementation ( ( url : string ) => {
34+ vi . spyOn ( global , 'fetch' ) . mockImplementation ( ( input : string | Request | URL , _init ?: RequestInit ) => {
35+ const url = typeof input === 'string' ? input : input . toString ( ) ;
3536 const key = url . includes ( 'passport-no-nationality' )
3637 ? 'passport-no-nationality'
3738 : url . includes ( 'name-dob' )
@@ -55,7 +56,8 @@ describe('protocolStore.fetch_ofac_trees', () => {
5556 'name-yob' : { status : 'success' , data : { root : [ 'yob' ] } } ,
5657 } ;
5758
58- vi . spyOn ( global , 'fetch' ) . mockImplementation ( ( url : string ) => {
59+ vi . spyOn ( global , 'fetch' ) . mockImplementation ( ( input : string | Request | URL , _init ?: RequestInit ) => {
60+ const url = typeof input === 'string' ? input : input . toString ( ) ;
5961 const key = url . includes ( 'passport-no-nationality' )
6062 ? 'passport-no-nationality'
6163 : url . includes ( 'name-dob' )
You can’t perform that action at this time.
0 commit comments