mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-03 02:21:44 +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.
69 lines
2.8 KiB
TypeScript
69 lines
2.8 KiB
TypeScript
/**
|
|
* Unit Tests: COBOL Copy Expander — pseudotext REPLACING support
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { parseReplacingClause } from '../../src/core/ingestion/cobol/cobol-copy-expander.js';
|
|
|
|
describe('parseReplacingClause', () => {
|
|
// Existing quoted-string behavior preserved
|
|
it('parses quoted EXACT replacement', () => {
|
|
const result = parseReplacingClause(' "OLD-NAME" BY "NEW-NAME" ');
|
|
expect(result).toEqual([{ type: 'EXACT', from: 'OLD-NAME', to: 'NEW-NAME' }]);
|
|
});
|
|
|
|
it('parses LEADING replacement', () => {
|
|
const result = parseReplacingClause(' LEADING "ESP-" BY "LK-ESP-" ');
|
|
expect(result).toEqual([{ type: 'LEADING', from: 'ESP-', to: 'LK-ESP-' }]);
|
|
});
|
|
|
|
it('parses TRAILING replacement', () => {
|
|
const result = parseReplacingClause(' TRAILING "-IN" BY "-OUT" ');
|
|
expect(result).toEqual([{ type: 'TRAILING', from: '-IN', to: '-OUT' }]);
|
|
});
|
|
|
|
// Pseudotext ==...== support (isPseudotext flag propagated)
|
|
it('parses basic pseudotext: ==OLD== BY ==NEW==', () => {
|
|
const result = parseReplacingClause(' ==WS-OLD== BY ==WS-NEW== ');
|
|
expect(result).toEqual([{ type: 'EXACT', from: 'WS-OLD', to: 'WS-NEW', isPseudotext: true }]);
|
|
});
|
|
|
|
it('parses empty pseudotext (deletion): ==TEXT== BY ====', () => {
|
|
const result = parseReplacingClause(' ==REMOVE-ME== BY ==== ');
|
|
expect(result).toEqual([{ type: 'EXACT', from: 'REMOVE-ME', to: '', isPseudotext: true }]);
|
|
});
|
|
|
|
it('parses pseudotext with spaces: ==SOME TEXT== BY ==OTHER TEXT==', () => {
|
|
const result = parseReplacingClause(' ==WORKING STORAGE== BY ==LOCAL STORAGE== ');
|
|
expect(result).toEqual([
|
|
{ type: 'EXACT', from: 'WORKING STORAGE', to: 'LOCAL STORAGE', isPseudotext: true },
|
|
]);
|
|
});
|
|
|
|
it('parses pseudotext with single = inside: ==A=B== BY ==C=D==', () => {
|
|
const result = parseReplacingClause(' ==A=B== BY ==C=D== ');
|
|
expect(result).toEqual([{ type: 'EXACT', from: 'A=B', to: 'C=D', isPseudotext: true }]);
|
|
});
|
|
|
|
it('parses mixed quoted + pseudotext in one clause', () => {
|
|
const result = parseReplacingClause(' "OLD-NAME" BY "NEW-NAME" ==DEL-PREFIX== BY ==== ');
|
|
expect(result).toEqual([
|
|
{ type: 'EXACT', from: 'OLD-NAME', to: 'NEW-NAME' },
|
|
{ type: 'EXACT', from: 'DEL-PREFIX', to: '', isPseudotext: true },
|
|
]);
|
|
});
|
|
|
|
it('LEADING modifier works alongside pseudotext', () => {
|
|
const result = parseReplacingClause(
|
|
' LEADING "ESP-" BY "LK-ESP-" ==OLD-EXACT== BY ==NEW-EXACT== ',
|
|
);
|
|
expect(result).toEqual([
|
|
{ type: 'LEADING', from: 'ESP-', to: 'LK-ESP-' },
|
|
{ type: 'EXACT', from: 'OLD-EXACT', to: 'NEW-EXACT', isPseudotext: true },
|
|
]);
|
|
});
|
|
|
|
it('returns empty array for empty input', () => {
|
|
expect(parseReplacingClause('')).toEqual([]);
|
|
expect(parseReplacingClause(' ')).toEqual([]);
|
|
});
|
|
});
|