diff --git a/test/__snapshots__/storageFileApi.test.ts.snap b/test/__snapshots__/storageFileApi.test.ts.snap new file mode 100644 index 0000000..cc88772 --- /dev/null +++ b/test/__snapshots__/storageFileApi.test.ts.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`get public URL 1`] = ` +Object { + "publicURL": "/object/public/my-new-bucket-1622499505045/profiles/myUniqueUserId/profile.png", +} +`; + +exports[`get public URL 2`] = `"http://localhost:8000/storage/v1/object/public/my-new-bucket-1622499505045/profiles/myUniqueUserId/profile.png"`; diff --git a/test/storageFileApi.test.ts b/test/storageFileApi.test.ts new file mode 100644 index 0000000..da0077d --- /dev/null +++ b/test/storageFileApi.test.ts @@ -0,0 +1,16 @@ +import { SupabaseStorageClient } from '../src/index' + +// TODO: need to setup storage-api server for this test +const URL = 'http://localhost:8000/storage/v1' +const KEY = + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIzMTdlYWRjZS02MzFhLTQ0MjktYTBiYi1mMTlhN2E1MTdiNGEiLCJSb2xlIjoicG9zdGdyZXMifQ.pZobPtp6gDcX0UbzMmG3FHSlg4m4Q-22tKtGWalOrNo' + +const storage = new SupabaseStorageClient(URL, { Authorization: `Bearer ${KEY}` }) +const newBucketName = `my-new-bucket-${Date.now()}` + +test('get public URL', async () => { + const res = storage.from(newBucketName).getPublicUrl('profiles/myUniqueUserId/profile.png') + expect(res.error).toBeNull() + expect(res.data).toMatchSnapshot() + expect(res.publicURL).toMatchSnapshot() +})