Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/SupabaseAuthClient.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SupabaseAuthClient } from '../src/lib/SupabaseAuthClient'

const DEFAULT_OPTIONS = {
schema: 'public',
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true,
headers: {},
}
const settings = { ...DEFAULT_OPTIONS }

test('it should create a new instance of the class', () => {
const authClient = new SupabaseAuthClient(settings)
expect(authClient).toBeInstanceOf(SupabaseAuthClient)
})
13 changes: 9 additions & 4 deletions test/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { createClient } from '../src/index'
import { createClient, SupabaseClient } from '../src/index'

const URL = 'http://localhost:3000'
const KEY = 'some.fake.key'

const supabase = createClient(URL, KEY)

test('Build to succeed', async () => {
// Basic test to ensure TS build is working.
expect(true).toEqual(true)
test('it should create the client connection', async () => {
expect(supabase).toBeDefined()
expect(supabase).toBeInstanceOf(SupabaseClient)
})

test('it should throw an error if no valid params are provided', async () => {
expect(() => createClient('', KEY)).toThrowError('supabaseUrl is required.')
expect(() => createClient(URL, '')).toThrowError('supabaseKey is required.')
})

// Socket should close when there are no open connections
Expand Down
12 changes: 12 additions & 0 deletions test/constants.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DEFAULT_HEADERS } from '../src/lib/constants'
import { version } from '../src/lib/version'

test('it has the correct type of returning with the correct value', () => {
const expected = {
'X-Client-Info': `supabase-js/${version}`,
}
expect(DEFAULT_HEADERS).toEqual(expected)
expect(typeof DEFAULT_HEADERS).toBe('object')
expect(typeof DEFAULT_HEADERS['X-Client-Info']).toBe('string')
expect(Object.keys(DEFAULT_HEADERS).length).toBe(1)
})