|
@@ -1,6 +1,6 @@
|
|
|
import { describe, test, expect, beforeAll, afterAll, vi } from 'vitest'
|
|
import { describe, test, expect, beforeAll, afterAll, vi } from 'vitest'
|
|
|
-import { createTestClient } from 'hono/testing'
|
|
|
|
|
-import app from '../index'
|
|
|
|
|
|
|
+import { testClient } from 'hono/testing'
|
|
|
|
|
+import { agoraApiRoutes } from '@/server/api'
|
|
|
import { AgoraTokenService } from '@/server/modules/agora/agora-token.service'
|
|
import { AgoraTokenService } from '@/server/modules/agora/agora-token.service'
|
|
|
|
|
|
|
|
// 模拟AgoraTokenService
|
|
// 模拟AgoraTokenService
|
|
@@ -20,13 +20,16 @@ vi.mock('@/server/modules/agora/agora-token.service', () => ({
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
describe('Agora Token API 集成测试', () => {
|
|
describe('Agora Token API 集成测试', () => {
|
|
|
- const client = createTestClient(app)
|
|
|
|
|
|
|
+ let client: ReturnType<typeof testClient<typeof agoraApiRoutes>>['api']['v1']
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
beforeAll(() => {
|
|
|
// 设置测试环境变量
|
|
// 设置测试环境变量
|
|
|
process.env.AGORA_APP_ID = 'test-app-id'
|
|
process.env.AGORA_APP_ID = 'test-app-id'
|
|
|
process.env.AGORA_APP_SECRET = 'test-app-secret'
|
|
process.env.AGORA_APP_SECRET = 'test-app-secret'
|
|
|
process.env.AGORA_TOKEN_EXPIRY = '3600'
|
|
process.env.AGORA_TOKEN_EXPIRY = '3600'
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试客户端
|
|
|
|
|
+ client = testClient(agoraApiRoutes).api.v1
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
afterAll(() => {
|