Skip to content

Commit

Permalink
feat: Added basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dshukertjr committed May 31, 2021
1 parent 3c4f604 commit 0853060
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/__snapshots__/storageFileApi.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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"`;
16 changes: 16 additions & 0 deletions test/storageFileApi.test.ts
Original file line number Diff line number Diff line change
@@ -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()
})

0 comments on commit 0853060

Please sign in to comment.