test: add comprehensive unit tests for database, parsers, loaders, and MCP tools
- Database layer tests (32 tests): - node-repository.ts: 100% coverage - template-repository.ts: 80.31% coverage - database-adapter.ts: interface compliance tests - Parser tests (99 tests): - node-parser.ts: 93.10% coverage - property-extractor.ts: 95.18% coverage - simple-parser.ts: 91.26% coverage - Fixed parser bugs for version extraction - Loader tests (22 tests): - node-loader.ts: comprehensive mocking tests - MCP tools tests (85 tests): - tools.ts: 100% coverage - tools-documentation.ts: 100% coverage - docs-mapper.ts: 100% coverage Total: 943 tests passing across 32 test files Significant progress from 2.45% to ~30% overall coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -128,21 +128,15 @@ export class NodeParser {
|
||||
}
|
||||
|
||||
private extractVersion(nodeClass: any): string {
|
||||
// Handle VersionedNodeType with defaultVersion
|
||||
if (nodeClass.baseDescription?.defaultVersion) {
|
||||
return nodeClass.baseDescription.defaultVersion.toString();
|
||||
}
|
||||
|
||||
// Handle VersionedNodeType with nodeVersions
|
||||
if (nodeClass.nodeVersions) {
|
||||
const versions = Object.keys(nodeClass.nodeVersions);
|
||||
return Math.max(...versions.map(Number)).toString();
|
||||
}
|
||||
|
||||
// Check instance for nodeVersions and version arrays
|
||||
// Check instance for baseDescription first
|
||||
try {
|
||||
const instance = typeof nodeClass === 'function' ? new nodeClass() : nodeClass;
|
||||
|
||||
// Handle instance-level baseDescription
|
||||
if (instance?.baseDescription?.defaultVersion) {
|
||||
return instance.baseDescription.defaultVersion.toString();
|
||||
}
|
||||
|
||||
// Handle instance-level nodeVersions
|
||||
if (instance?.nodeVersions) {
|
||||
const versions = Object.keys(instance.nodeVersions);
|
||||
@@ -162,7 +156,18 @@ export class NodeParser {
|
||||
}
|
||||
} catch (e) {
|
||||
// Some nodes might require parameters to instantiate
|
||||
// Try to get version from class-level description
|
||||
// Try class-level properties
|
||||
}
|
||||
|
||||
// Handle class-level VersionedNodeType with defaultVersion
|
||||
if (nodeClass.baseDescription?.defaultVersion) {
|
||||
return nodeClass.baseDescription.defaultVersion.toString();
|
||||
}
|
||||
|
||||
// Handle class-level VersionedNodeType with nodeVersions
|
||||
if (nodeClass.nodeVersions) {
|
||||
const versions = Object.keys(nodeClass.nodeVersions);
|
||||
return Math.max(...versions.map(Number)).toString();
|
||||
}
|
||||
|
||||
// Also check class-level description for version array
|
||||
@@ -181,15 +186,15 @@ export class NodeParser {
|
||||
}
|
||||
|
||||
private detectVersioned(nodeClass: any): boolean {
|
||||
// Check class-level nodeVersions
|
||||
if (nodeClass.nodeVersions || nodeClass.baseDescription?.defaultVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check instance-level nodeVersions and version arrays
|
||||
// Check instance-level properties first
|
||||
try {
|
||||
const instance = typeof nodeClass === 'function' ? new nodeClass() : nodeClass;
|
||||
|
||||
// Check for instance baseDescription with defaultVersion
|
||||
if (instance?.baseDescription?.defaultVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for nodeVersions
|
||||
if (instance?.nodeVersions) {
|
||||
return true;
|
||||
@@ -201,7 +206,12 @@ export class NodeParser {
|
||||
}
|
||||
} catch (e) {
|
||||
// Some nodes might require parameters to instantiate
|
||||
// Try to check class-level description
|
||||
// Try class-level checks
|
||||
}
|
||||
|
||||
// Check class-level nodeVersions
|
||||
if (nodeClass.nodeVersions || nodeClass.baseDescription?.defaultVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Also check class-level description for version array
|
||||
|
||||
@@ -187,9 +187,28 @@ export class SimpleParser {
|
||||
}
|
||||
|
||||
private extractVersion(nodeClass: any): string {
|
||||
// Try to get version from instance first
|
||||
try {
|
||||
const instance = typeof nodeClass === 'function' ? new nodeClass() : nodeClass;
|
||||
|
||||
// Check instance baseDescription
|
||||
if (instance?.baseDescription?.defaultVersion) {
|
||||
return instance.baseDescription.defaultVersion.toString();
|
||||
}
|
||||
|
||||
// Check instance description version
|
||||
if (instance?.description?.version) {
|
||||
return instance.description.version.toString();
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore instantiation errors
|
||||
}
|
||||
|
||||
// Check class-level properties
|
||||
if (nodeClass.baseDescription?.defaultVersion) {
|
||||
return nodeClass.baseDescription.defaultVersion.toString();
|
||||
}
|
||||
|
||||
return nodeClass.description?.version || '1';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user