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

describe('StripePlugin - Initialization', () => {
it('should initialize with correct plugin name and options', () => {
const plugin = new StripePlugin({
apiKey: 'sk_test_123',
endpointSecret: 'whsec_abc',
})
expect(plugin).toBeInstanceOf(StripePlugin)
expect(plugin.name).toBe('starbasedb:stripe')
expect(plugin.apiKey).toBe('sk_test_123')
expect(plugin.endpointSecret).toBe('whsec_abc')
})

it('should initialize with empty options without throwing', () => {
const plugin = new StripePlugin()
expect(plugin).toBeInstanceOf(StripePlugin)
expect(plugin.apiKey).toBeUndefined()
expect(plugin.endpointSecret).toBeUndefined()
})
})

describe('StripePlugin - Route Registration', () => {
let plugin: StripePlugin
let mockApp: any
let registeredRoutes: Record<string, Function> = {}

beforeEach(() => {
plugin = new StripePlugin({ apiKey: 'sk_test_123' })
registeredRoutes = {}

mockApp = {
use: vi.fn(),
post: vi.fn((path: string, handler: Function) => {
registeredRoutes[path] = handler
}),
}
})

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