forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpclient-exposed.test.ts
More file actions
33 lines (30 loc) · 1.01 KB
/
Copy pathhttpclient-exposed.test.ts
File metadata and controls
33 lines (30 loc) · 1.01 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
import { describe, it, expect } from 'vitest';
import { LilySdk } from '../src/sdk';
describe('HttpClient exposed on instance (issue #57)', () => {
it('sdk.httpClient returns the active HttpClient', () => {
const sdk = new LilySdk({
baseUrl: 'https://api.lily.io',
apiKey: 'k_test',
});
expect(sdk.httpClient).toBeDefined();
expect(typeof sdk.httpClient.request).toBe('function');
});
it('custom HttpClient is exposed via getter', () => {
const customClient = {
request: async () => ({ status: 200, headers: new Headers(), data: {} }),
};
const sdk = new LilySdk(
{ baseUrl: 'https://api.lily.io' },
customClient as any,
);
expect(sdk.httpClient).toBe(customClient);
});
it('httpClient is the same instance used by all clients', () => {
const sdk = new LilySdk({
baseUrl: 'https://api.lily.io',
apiKey: 'k_test',
});
// The httpClient getter should return the same instance
expect(sdk.httpClient).toBe(sdk.httpClient);
});
});