forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdist-smoke.test.ts
More file actions
37 lines (33 loc) · 1.33 KB
/
Copy pathdist-smoke.test.ts
File metadata and controls
37 lines (33 loc) · 1.33 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
import { describe, expect, it } from 'vitest';
import { createRequire } from 'node:module';
import { resolve } from 'node:path';
const require = createRequire(import.meta.url);
const distEsm = resolve(__dirname, '..', 'dist', 'index.js');
const distCjs = resolve(__dirname, '..', 'dist', 'index.cjs');
describe('dist smoke test', () => {
it('ESM import exposes LilySdk, a client, and an error class', async () => {
const mod = await import(distEsm);
expect(mod.LilySdk).toBeTypeOf('function');
expect(mod.AgentClient).toBeTypeOf('function');
expect(mod.LilySdkError).toBeTypeOf('function');
expect(mod.LilyApiError).toBeTypeOf('function');
});
it('CJS require exposes LilySdk, a client, and an error class', () => {
const mod = require(distCjs);
expect(mod.LilySdk).toBeTypeOf('function');
expect(mod.AgentClient).toBeTypeOf('function');
expect(mod.LilySdkError).toBeTypeOf('function');
expect(mod.LilyApiError).toBeTypeOf('function');
});
it('ESM and CJS expose the same public symbol names', async () => {
const esm = await import(distEsm);
const cjs = require(distCjs);
const esmKeys = Object.keys(esm)
.filter((k) => k !== 'default')
.sort();
const cjsKeys = Object.keys(cjs)
.filter((k) => k !== 'default')
.sort();
expect(esmKeys).toEqual(cjsKeys);
});
});