forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent-client-delete.test.ts
More file actions
52 lines (46 loc) · 1.66 KB
/
Copy pathagent-client-delete.test.ts
File metadata and controls
52 lines (46 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { describe, it, expect, vi } from 'vitest';
import { AgentClient } from '../src/clients/agent-client';
import type { HttpClient, HttpResponse } from '../src/http/types';
function createMockClient(): { client: AgentClient; mock: HttpClient } {
const mock: HttpClient = {
request: vi.fn().mockResolvedValue({
status: 204,
headers: new Headers(),
data: null,
} satisfies HttpResponse),
};
return { client: new AgentClient(mock), mock };
}
describe('AgentClient.delete (issue #63)', () => {
it('sends DELETE /v1/agents/:agentId', async () => {
const { client, mock } = createMockClient();
await client.delete('agent-123');
expect(mock.request).toHaveBeenCalledWith({
method: 'DELETE',
path: '/v1/agents/agent-123',
});
});
it('passes agent ID into the URL path', async () => {
const { client, mock } = createMockClient();
await client.delete('agent-456');
const call = (mock.request as any).mock.calls[0][0];
expect(call.path).toBe('/v1/agents/agent-456');
});
it('does not send a body', async () => {
const { client, mock } = createMockClient();
await client.delete('agent-789');
const call = (mock.request as any).mock.calls[0][0];
expect(call.body).toBeUndefined();
});
it('returns void on success', async () => {
const { client } = createMockClient();
const result = await client.delete('agent-abc');
expect(result).toBeNull();
});
it('uses DELETE method', async () => {
const { client, mock } = createMockClient();
await client.delete('agent-xyz');
const call = (mock.request as any).mock.calls[0][0];
expect(call.method).toBe('DELETE');
});
});