SnowLuma v2.4.2 source snapshot
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
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
This commit is contained in:
commit
fa9c73363d
1367 files changed
+355735
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { FriendDressError } from '@snowluma/protocol/web/friend-dress';
|
||||
import { ApiHandler, type ApiActionContext } from '../src/api-handler';
|
||||
|
||||
function makeHandler(getFriendDress: ReturnType<typeof vi.fn>): ApiHandler {
|
||||
const bridge = { apis: { web: { getFriendDress } } };
|
||||
return new ApiHandler({ bridge } as unknown as ApiActionContext);
|
||||
}
|
||||
|
||||
describe('_get_friend_dress action', () => {
|
||||
it('validates the target and returns the queried dress data', async () => {
|
||||
const dress = {
|
||||
target_uin: '10000',
|
||||
is_svip: false,
|
||||
avatar_url: '',
|
||||
items: [],
|
||||
};
|
||||
const getFriendDress = vi.fn().mockResolvedValue(dress);
|
||||
|
||||
const response = await makeHandler(getFriendDress).handle('_get_friend_dress', {
|
||||
user_id: '10000',
|
||||
});
|
||||
|
||||
expect(response).toMatchObject({ status: 'ok', retcode: 0, data: dress });
|
||||
expect(getFriendDress).toHaveBeenCalledWith(10000);
|
||||
});
|
||||
|
||||
it('preserves the structured failure kind in the Action response', async () => {
|
||||
const getFriendDress = vi
|
||||
.fn()
|
||||
.mockRejectedValue(
|
||||
new FriendDressError('uin_mismatch', 'returned account does not match'),
|
||||
);
|
||||
|
||||
const response = await makeHandler(getFriendDress).handle('_get_friend_dress', {
|
||||
user_id: 10000,
|
||||
});
|
||||
|
||||
expect(response).toMatchObject({ status: 'failed', retcode: 100 });
|
||||
expect(response.wording).toContain('(uin_mismatch)');
|
||||
expect(response.wording).toContain('returned account does not match');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user