31 lines
911 B
TypeScript
31 lines
911 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { getSupabaseClient, isSupabaseConfigured } from '@/lib/supabase'
|
|
import type { AppConfig } from '@/config/env'
|
|
|
|
const base: AppConfig = {
|
|
siteName: 'S',
|
|
brandName: 'B',
|
|
footerName: 'F',
|
|
tagline: 'T',
|
|
supabase: null,
|
|
authProviders: [],
|
|
}
|
|
|
|
describe('getSupabaseClient', () => {
|
|
it('returns null when no backend is configured (current default)', () => {
|
|
expect(getSupabaseClient(base)).toBeNull()
|
|
expect(isSupabaseConfigured(base)).toBe(false)
|
|
})
|
|
|
|
it('creates one client per connection and reuses it', () => {
|
|
const configured: AppConfig = {
|
|
...base,
|
|
supabase: { url: 'http://127.0.0.1:54321', anonKey: 'anon' },
|
|
}
|
|
const first = getSupabaseClient(configured)
|
|
expect(first).not.toBeNull()
|
|
expect(getSupabaseClient(configured)).toBe(first)
|
|
expect(isSupabaseConfigured(configured)).toBe(true)
|
|
})
|
|
})
|