mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-08-28 05:25:25 +00:00
* feat: configure prettier with pre-commit hook integration Add prettier, lint-staged, and prettier-plugin-tailwindcss at the repo root with husky pre-commit hook integration. Moves husky from gitnexus/ to root package.json for reliable hook installation. - Root package.json with prepare/format/format:check scripts - .prettierrc with endOfLine:lf and tailwindStylesheet for TW v4 - .prettierignore excluding fixtures, vendor, generated, *.d.ts, *.md - .gitattributes enforcing LF line endings for Windows consistency - Pre-commit hook uses direct node_modules/.bin/ paths (no npx) * style: apply prettier formatting to entire codebase One-time bulk format. No logic changes. Use .git-blame-ignore-revs to skip this commit in git blame. * chore: add .git-blame-ignore-revs for prettier format commit * perf: pre-commit hook runs only tests related to staged files Use vitest --related to scope test execution to tests that import the changed files, instead of running the full suite on every commit. * perf: remove vitest from pre-commit hook, keep in CI only Pre-commit now runs lint-staged + tsc only. Tests run in CI (ci-tests.yml) where they belong — keeps commits fast. * ci: add prettier format check to quality workflow PRs will now fail if code isn't formatted with prettier.
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { createKnowledgeGraph } from '../../src/core/graph/graph';
|
|
import {
|
|
createFileNode,
|
|
createFunctionNode,
|
|
createCallsRelationship,
|
|
createContainsRelationship,
|
|
} from '../fixtures/graph';
|
|
|
|
describe('createKnowledgeGraph', () => {
|
|
it('starts empty', () => {
|
|
const graph = createKnowledgeGraph();
|
|
expect(graph.nodeCount).toBe(0);
|
|
expect(graph.relationshipCount).toBe(0);
|
|
expect(graph.nodes).toEqual([]);
|
|
expect(graph.relationships).toEqual([]);
|
|
});
|
|
|
|
it('adds nodes', () => {
|
|
const graph = createKnowledgeGraph();
|
|
const node = createFileNode('index.ts', 'src/index.ts');
|
|
graph.addNode(node);
|
|
|
|
expect(graph.nodeCount).toBe(1);
|
|
expect(graph.nodes[0].id).toBe('File:src/index.ts');
|
|
});
|
|
|
|
it('deduplicates nodes by id', () => {
|
|
const graph = createKnowledgeGraph();
|
|
const node = createFileNode('index.ts', 'src/index.ts');
|
|
const duplicateNode = createFileNode('index.ts', 'src/index.ts');
|
|
graph.addNode(node);
|
|
graph.addNode(duplicateNode);
|
|
|
|
expect(graph.nodeCount).toBe(1);
|
|
});
|
|
|
|
it('adds relationships', () => {
|
|
const graph = createKnowledgeGraph();
|
|
const rel = createCallsRelationship('fn:a', 'fn:b');
|
|
graph.addRelationship(rel);
|
|
|
|
expect(graph.relationshipCount).toBe(1);
|
|
expect(graph.relationships[0].type).toBe('CALLS');
|
|
});
|
|
|
|
it('deduplicates relationships by id', () => {
|
|
const graph = createKnowledgeGraph();
|
|
const rel = createCallsRelationship('fn:a', 'fn:b');
|
|
const duplicateRel = createCallsRelationship('fn:a', 'fn:b');
|
|
graph.addRelationship(rel);
|
|
graph.addRelationship(duplicateRel);
|
|
|
|
expect(graph.relationshipCount).toBe(1);
|
|
});
|
|
|
|
it('builds a multi-node graph', () => {
|
|
const graph = createKnowledgeGraph();
|
|
const file = createFileNode('app.ts', 'src/app.ts');
|
|
const fn1 = createFunctionNode('main', 'src/app.ts', 1);
|
|
const fn2 = createFunctionNode('helper', 'src/app.ts', 20);
|
|
|
|
graph.addNode(file);
|
|
graph.addNode(fn1);
|
|
graph.addNode(fn2);
|
|
graph.addRelationship(createContainsRelationship(file.id, fn1.id));
|
|
graph.addRelationship(createContainsRelationship(file.id, fn2.id));
|
|
graph.addRelationship(createCallsRelationship(fn1.id, fn2.id));
|
|
|
|
expect(graph.nodeCount).toBe(3);
|
|
expect(graph.relationshipCount).toBe(3);
|
|
});
|
|
});
|