mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
import type { HttpClient } from '@/http/types'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { PermittedExternalAppsClient } from './permitted-external-apps'
|
|
|
|
function fakeHttp() {
|
|
return { baseURL: 'https://x', request: vi.fn() } as unknown as HttpClient
|
|
}
|
|
|
|
type WithOrpc = { orpc: unknown }
|
|
|
|
describe('PermittedExternalAppsClient', () => {
|
|
it('list calls permittedExternalApps.get with paging/filter query', async () => {
|
|
const c = new PermittedExternalAppsClient(fakeHttp())
|
|
const get = vi.fn().mockResolvedValue({ page: 1, limit: 20, total: 0, has_more: false, data: [] })
|
|
;(c as unknown as WithOrpc).orpc = { permittedExternalApps: { get, byAppId: { describe: { get: vi.fn() } } } }
|
|
await c.list({ workspaceId: '', page: 2, limit: 5, mode: undefined, name: 'a' })
|
|
expect(get).toHaveBeenCalledWith({ query: { page: 2, limit: 5, mode: undefined, name: 'a' } })
|
|
})
|
|
|
|
it('describe calls permittedExternalApps.byAppId.describe.get with app_id + fields', async () => {
|
|
const c = new PermittedExternalAppsClient(fakeHttp())
|
|
const dget = vi.fn().mockResolvedValue({ info: null, parameters: null, input_schema: null })
|
|
;(c as unknown as WithOrpc).orpc = { permittedExternalApps: { get: vi.fn(), byAppId: { describe: { get: dget } } } }
|
|
await c.describe('app-1', ['info'])
|
|
expect(dget).toHaveBeenCalledWith({ params: { app_id: 'app-1' }, query: { fields: 'info' } })
|
|
})
|
|
})
|