@@ -37,17 +37,17 @@ describe('Bucket API Error Handling', () => {
37
37
const urlTestCases = [
38
38
[
39
39
'https://blah.supabase.co/storage/v1' ,
40
- 'https://blah.storage.supabase.co/v1' ,
40
+ 'https://blah.storage.supabase.co/storage/ v1' ,
41
41
'update legacy prod host to new host' ,
42
42
] ,
43
43
[
44
44
'https://blah.supabase.red/storage/v1' ,
45
- 'https://blah.storage.supabase.red/v1' ,
45
+ 'https://blah.storage.supabase.red/storage/ v1' ,
46
46
'update legacy staging host to new host' ,
47
47
] ,
48
48
[
49
- 'https://blah.storage.supabase.co/v1' ,
50
- 'https://blah.storage.supabase.co/v1' ,
49
+ 'https://blah.storage.supabase.co/storage/ v1' ,
50
+ 'https://blah.storage.supabase.co/storage/ v1' ,
51
51
'accept new host without modification' ,
52
52
] ,
53
53
[
@@ -63,16 +63,30 @@ describe('Bucket API Error Handling', () => {
63
63
]
64
64
65
65
urlTestCases . forEach ( ( [ inputUrl , expectUrl , description ] ) => {
66
- it ( 'should ' + description , ( ) => {
66
+ it ( 'should ' + description + ' if useNewHostname is true' , ( ) => {
67
67
const storage = new StorageClient ( inputUrl , { apikey : KEY } , undefined , {
68
68
useNewHostname : true ,
69
69
} )
70
70
expect ( storage [ 'url' ] ) . toBe ( expectUrl )
71
71
} )
72
+ it ( 'should not modify host if useNewHostname is false' , ( ) => {
73
+ const storage = new StorageClient ( inputUrl , { apikey : KEY } , undefined , {
74
+ useNewHostname : false ,
75
+ } )
76
+ expect ( storage [ 'url' ] ) . toBe ( inputUrl )
77
+ } )
72
78
} )
73
79
} )
74
80
75
81
describe ( 'listBuckets' , ( ) => {
82
+ it ( 'handles missing authorization errors if header is not provided' , async ( ) => {
83
+ const storage = new StorageClient ( URL )
84
+ const { data, error } = await storage . listBuckets ( )
85
+ expect ( data ) . toBeNull ( )
86
+ expect ( error ) . not . toBeNull ( )
87
+ expect ( error ?. message ) . toBe ( `headers must have required property 'authorization'` )
88
+ } )
89
+
76
90
it ( 'handles network errors' , async ( ) => {
77
91
const mockError = new Error ( 'Network failure' )
78
92
global . fetch = jest . fn ( ) . mockImplementation ( ( ) => Promise . reject ( mockError ) )
0 commit comments