Add 34 tests (27 unit, 7 integration) using node:test runner: Unit tests: - pickServer(), findRoot(), pathToUri(), uriToPath() - isLspCommand(), listCommands() - formatHover(), formatDefinition(), formatReferences(), formatDiagnostics() Integration tests: - daemon lifecycle (status/stop) on isolated socket - CLI --no-daemon queries (hover, documentSymbol, diagnostics) Supporting changes: - socketPath() honors PI_LSP_SOCKET_PATH env var for test isolation - test fixtures for valid and broken TypeScript files - npm test / test:unit / test:integration scripts
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
// Sample Fixture — Minimal TypeScript file with known symbols for LSP testing.
|
|
// Used by integration tests to validate hover, definition, references, etc.
|
|
|
|
/**
|
|
* A sample class for testing LSP features.
|
|
* @example new SampleClass("hello")
|
|
*/
|
|
export class SampleClass {
|
|
public readonly name: string;
|
|
|
|
constructor(name: string) {
|
|
this.name = name;
|
|
}
|
|
|
|
/** Returns a greeting using the instance name. */
|
|
greet(): string {
|
|
return `Hello, ${this.name}!`;
|
|
}
|
|
}
|
|
|
|
/** A constant value for reference testing. */
|
|
export const SAMPLE_CONSTANT = 42;
|
|
|
|
/** Creates a new SampleClass with a default name. */
|
|
export function createSample(): SampleClass {
|
|
return new SampleClass("default");
|
|
}
|
|
|
|
// Internal helper — not exported, used to test definition lookups.
|
|
function internalHelper(value: number): string {
|
|
return String(value);
|
|
}
|
|
|
|
/** Uses the internal helper and constant for cross-reference testing. */
|
|
export function useInternal(): string {
|
|
const instance = createSample();
|
|
return internalHelper(SAMPLE_CONSTANT) + instance.greet();
|
|
}
|