From 3ac7c3c79459cf9afde46669cceb72428e550c4f Mon Sep 17 00:00:00 2001 From: GabrielHFGoncalez <125215011+GabrielHFGoncalez@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:09:26 -0300 Subject: [PATCH] test(clerk): add Vitest unit test suite (closes #71) --- plugins/clerk/index.test.ts | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 plugins/clerk/index.test.ts diff --git a/plugins/clerk/index.test.ts b/plugins/clerk/index.test.ts new file mode 100644 index 0000000..75fb277 --- /dev/null +++ b/plugins/clerk/index.test.ts @@ -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() + }) +})