Files
SnowLuma/packages/onebot/tests/actions-group-file.test.ts
TanTan fa9c73363d
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
SnowLuma v2.4.2 source snapshot
2026-11-13 09:02:00 +08:00

29 lines
1.3 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import type { ApiActionContext } from '../src/api-handler';
import { actions } from '../src/actions/group-file';
describe('get_group_file_url storage selection', () => {
it.each([
{ busid: undefined, expected: undefined },
{ busid: null, expected: undefined },
{ busid: '', expected: undefined },
{ busid: 'invalid', expected: undefined },
{ busid: -1, expected: undefined },
{ busid: 102, expected: 102 },
{ busid: '104', expected: 104 },
{ busid: 0, expected: 0 },
])(
'passes an explicit valid type, otherwise lets the file cache select it (%j)',
async ({ busid, expected }) => {
const getUrl = vi.fn(async () => 'https://download.example.com/file');
const ctx = {
bridge: { apis: { groupFile: { getUrl } } },
} as unknown as ApiActionContext;
const action = actions.find((entry) => entry.names[0] === 'get_group_file_url')!;
const result = await action.toHandler(ctx)({ group_id: 12345, file_id: 'temp', busid });
expect(result).toMatchObject({ status: 'ok' });
expect(getUrl).toHaveBeenCalledExactlyOnceWith(12345, 'temp', expected);
},
);
});