forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient-contracts.test.ts
More file actions
55 lines (49 loc) · 2.15 KB
/
Copy pathclient-contracts.test.ts
File metadata and controls
55 lines (49 loc) · 2.15 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
53
54
55
import { describe, it, expect } from 'vitest';
import type {
AgentClientContract,
WalletClientContract,
PaymentClientContract,
IdentityClientContract,
SystemClientContract,
} from '../src/types/contracts';
import { AgentClient } from '../src/clients/agent-client';
import { WalletClient } from '../src/clients/wallet-client';
import { PaymentClient } from '../src/clients/payment-client';
import { IdentityClient } from '../src/clients/identity-client';
import { SystemClient } from '../src/clients/system-client';
import type { HttpClient } from '../src/http/types';
function createMockHttpClient(): HttpClient {
return {
request: () => Promise.resolve({ status: 200, headers: new Headers(), data: {} as never }),
};
}
describe('client contract conformance', () => {
it('AgentClient satisfies AgentClientContract', () => {
const client: AgentClientContract = new AgentClient(createMockHttpClient());
expect(typeof client.list).toBe('function');
expect(typeof client.get).toBe('function');
expect(typeof client.create).toBe('function');
expect(typeof client.update).toBe('function');
});
it('WalletClient satisfies WalletClientContract', () => {
const client: WalletClientContract = new WalletClient(createMockHttpClient());
expect(typeof client.provision).toBe('function');
expect(typeof client.get).toBe('function');
});
it('PaymentClient satisfies PaymentClientContract', () => {
const client: PaymentClientContract = new PaymentClient(createMockHttpClient());
expect(typeof client.quote).toBe('function');
expect(typeof client.execute).toBe('function');
expect(typeof client.get).toBe('function');
});
it('IdentityClient satisfies IdentityClientContract', () => {
const client: IdentityClientContract = new IdentityClient(createMockHttpClient());
expect(typeof client.resolve).toBe('function');
expect(typeof client.verify).toBe('function');
});
it('SystemClient satisfies SystemClientContract', () => {
const client: SystemClientContract = new SystemClient(createMockHttpClient());
expect(typeof client.health).toBe('function');
expect(typeof client.info).toBe('function');
});
});