@@ -6,7 +6,7 @@ import FormData from 'form-data'
6
6
import assert from 'assert'
7
7
// @ts -ignore
8
8
import fetch , { Response } from '@supabase/node-fetch'
9
- import { StorageError } from '../src/lib/errors'
9
+ import { StorageApiError , StorageError } from '../src/lib/errors'
10
10
11
11
// TODO: need to setup storage-api server for this test
12
12
const URL = 'http://localhost:8000/storage/v1'
@@ -202,11 +202,10 @@ describe('Object API', () => {
202
202
} )
203
203
204
204
const res = await storage . from ( bucketName ) . upload ( uploadPath , file )
205
- expect ( res . error ) . toEqual ( {
206
- error : 'Payload too large' ,
207
- message : 'The object exceeded the maximum allowed size' ,
208
- statusCode : '413' ,
209
- } )
205
+
206
+ const outError = res . error as StorageApiError
207
+ expect ( outError ) . toBeInstanceOf ( StorageApiError )
208
+ expect ( outError . message ) . toBe ( 'The object exceeded the maximum allowed size' )
210
209
} )
211
210
212
211
test ( 'can upload a file with a valid mime type' , async ( ) => {
@@ -232,11 +231,9 @@ describe('Object API', () => {
232
231
const res = await storage . from ( bucketName ) . upload ( uploadPath , file , {
233
232
contentType : 'image/jpeg' ,
234
233
} )
235
- expect ( res . error ) . toEqual ( {
236
- error : 'invalid_mime_type' ,
237
- message : 'mime type image/jpeg is not supported' ,
238
- statusCode : '415' ,
239
- } )
234
+ const outError = res . error as StorageApiError
235
+ expect ( outError ) . toBeInstanceOf ( StorageApiError )
236
+ expect ( outError . message ) . toBe ( 'mime type image/jpeg is not supported' )
240
237
} )
241
238
242
239
test ( 'sign url for upload' , async ( ) => {
@@ -299,11 +296,9 @@ describe('Object API', () => {
299
296
. from ( bucketName )
300
297
. uploadToSignedUrl ( data . path , data . token , file )
301
298
302
- expect ( uploadRes2 . error ) . toEqual ( {
303
- error : 'Duplicate' ,
304
- message : 'The resource already exists' ,
305
- statusCode : '409' ,
306
- } )
299
+ const outError = uploadRes2 . error as StorageApiError
300
+ expect ( outError ) . toBeInstanceOf ( StorageApiError )
301
+ expect ( outError . message ) . toBe ( 'The resource already exists' )
307
302
} )
308
303
} )
309
304
0 commit comments