Skip to content
Open
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
41 changes: 41 additions & 0 deletions plugins/clerk/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { ClerkPlugin } from './index'

describe('ClerkPlugin - Initialization', () => {
it('should initialize with correct plugin name and keys', () => {
const plugin = new ClerkPlugin({
secretKey: 'sk_test_clerk_secret',
publishableKey: 'pk_test_clerk_pub',
})
expect(plugin).toBeInstanceOf(ClerkPlugin)
expect(plugin.name).toBe('starbasedb:clerk')
expect(plugin.secretKey).toBe('sk_test_clerk_secret')
expect(plugin.publishableKey).toBe('pk_test_clerk_pub')
})

it('should initialize gracefully when options are not passed', () => {
const plugin = new ClerkPlugin()
expect(plugin).toBeInstanceOf(ClerkPlugin)
expect(plugin.secretKey).toBeUndefined()
expect(plugin.publishableKey).toBeUndefined()
})
})

describe('ClerkPlugin - App Registration', () => {
let plugin: ClerkPlugin
let mockApp: any

beforeEach(() => {
plugin = new ClerkPlugin({ secretKey: 'sk_test_123' })
mockApp = {
use: vi.fn(),
post: vi.fn(),
get: vi.fn(),
}
})

it('should register middleware and endpoints on app instance', async () => {
await plugin.register(mockApp)
expect(mockApp.use).toHaveBeenCalled()
})
})