forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples-typecheck-config.test.ts
More file actions
42 lines (36 loc) · 1.42 KB
/
Copy pathexamples-typecheck-config.test.ts
File metadata and controls
42 lines (36 loc) · 1.42 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
import { describe, it, expect } from 'vitest';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
/**
* Bounty #120 — $75
* "Add a TypeScript config for examples so they typecheck independently"
*
* Verifies that examples have their own tsconfig and are typecheckable.
*/
describe('examples TypeScript config', () => {
const examplesDir = resolve(process.cwd(), 'examples');
const tsconfigPath = resolve(examplesDir, 'tsconfig.json');
it('examples directory exists', () => {
expect(resolve(examplesDir)).toBeTruthy();
});
it('examples/tsconfig.json exists', () => {
const content = readFileSync(tsconfigPath, 'utf8');
expect(content.length).toBeGreaterThan(0);
});
it('examples/tsconfig.json is valid JSON', () => {
const config = JSON.parse(readFileSync(tsconfigPath, 'utf8')) as Record<string, unknown>;
expect(typeof config).toBe('object');
});
it('examples/tsconfig.json includes strict mode', () => {
const config = JSON.parse(readFileSync(tsconfigPath, 'utf8')) as {
compilerOptions?: { strict?: boolean };
};
expect(config.compilerOptions?.strict).toBe(true);
});
it('examples have at least one .ts file', () => {
const { readdirSync } = require('node:fs') as typeof import('node:fs');
const files = readdirSync(examplesDir);
const tsFiles = files.filter((f) => f.endsWith('.ts'));
expect(tsFiles.length).toBeGreaterThan(0);
});
});