forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.test.ts
More file actions
57 lines (46 loc) · 2.2 KB
/
Copy pathcodegen.test.ts
File metadata and controls
57 lines (46 loc) · 2.2 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
56
57
import { describe, it, expect } from 'vitest';
import { existsSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path';
const ROOT = resolve(__dirname, '..');
describe('OpenAPI Codegen', () => {
it('generates src/generated/types.ts with auto-generated header', () => {
const generatedPath = resolve(ROOT, 'src', 'generated', 'types.ts');
expect(existsSync(generatedPath)).toBe(true);
const content = readFileSync(generatedPath, 'utf-8');
expect(content).toContain('AUTO-GENERATED FILE — DO NOT EDIT MANUALLY');
expect(content).toContain('Generated by scripts/codegen.ts from OpenAPI spec');
expect(content).toContain('To regenerate: npm run codegen');
});
it('vendored OpenAPI spec exists at openapi/lily-backend.yaml', () => {
const specPath = resolve(ROOT, 'openapi', 'lily-backend.yaml');
expect(existsSync(specPath)).toBe(true);
const content = readFileSync(specPath, 'utf-8');
expect(content).toContain('openapi: 3.0.3');
expect(content).toContain('Lily Protocol Backend API');
});
it('CODEGEN.md documentation exists', () => {
const docPath = resolve(ROOT, 'CODEGEN.md');
expect(existsSync(docPath)).toBe(true);
const content = readFileSync(docPath, 'utf-8');
expect(content).toContain('npm run codegen');
expect(content).toContain('openapi/lily-backend.yaml');
expect(content).toContain('src/generated/types.ts');
});
it('generated types include expected schema components', () => {
const generatedPath = resolve(ROOT, 'src', 'generated', 'types.ts');
const content = readFileSync(generatedPath, 'utf-8');
// Verify key schemas from the vendored spec are present
expect(content).toContain('HealthStatus');
expect(content).toContain('Agent');
expect(content).toContain('Wallet');
expect(content).toContain('Payment');
expect(content).toContain('IdentityProfile');
expect(content).toContain('VerificationResult');
});
it('package.json includes codegen script', () => {
const pkgPath = resolve(ROOT, 'package.json');
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
expect(pkg.scripts).toBeDefined();
expect(pkg.scripts.codegen).toBe('tsx scripts/codegen.ts');
});
});