Work through test-strategy-report.md, high-ROI no-refactor subset (no regen). - R-Infra: vitest resolve.alias docmost-client -> packages/docmost-client/src (fixes the dist-vs-src coverage artifact: canonicalize 0% -> real) - R-Cfg-1: export parseArgs + tests - canonicalize: align family / comment.resolved kept / link non-default + fixpoint & docsCanonicallyEqual reflexive/symmetric properties (0 -> 100%) - markdown-converter golden matrix: columns/embed/audio/pdf, drawio data-align rule, inline-mark matrix, textAlign, escaping idempotence, table sanitization (61 -> 79%) - schema parse-closures via generateJSON (TextStyle/comment/mention/Highlight/Column) - node-ops (immutability, table edge cases, makeFreshId property), transforms (setCalloutRange/insertMarkerAfter/commentsToFootnotes + renumber property) - stabilize normalize-on-write fixpoint (0 -> 100%); diff coarse-fallback; client-utils; firstDivergence; corpus fixtures details/columns/mention - 593 -> 695 green; build clean; corpus STABLE Deferred (Phase 3-4, refactor-gated): pull/collab/client-REST/git-merge integration.
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { parseArgs } from '../src/roundtrip.js';
|
|
|
|
// R-Cfg-1: parseArgs is exported so the CLI flag parsing is unit-testable. The
|
|
// tricky bits are the --corpus lookahead (its directory arg is optional and must
|
|
// NOT swallow a following flag), the `argv[++i]` value consumption for
|
|
// --fixture/--page, and the empty-argv default.
|
|
|
|
describe('parseArgs', () => {
|
|
it('returns an empty object for empty argv (no flags)', () => {
|
|
expect(parseArgs([])).toEqual({});
|
|
});
|
|
|
|
it('reads the value after --fixture (argv[++i])', () => {
|
|
expect(parseArgs(['--fixture', 'path/to/doc.json'])).toEqual({
|
|
fixture: 'path/to/doc.json',
|
|
});
|
|
});
|
|
|
|
it('reads the value after --page (argv[++i])', () => {
|
|
expect(parseArgs(['--page', 'page-123'])).toEqual({ page: 'page-123' });
|
|
});
|
|
|
|
it('--corpus consumes the directory when the next token is not a flag', () => {
|
|
expect(parseArgs(['--corpus', 'test/fixtures/corpus'])).toEqual({
|
|
corpus: 'test/fixtures/corpus',
|
|
});
|
|
});
|
|
|
|
it('--corpus uses the DEFAULT dir when followed by another flag (lookahead)', () => {
|
|
// The lookahead must NOT consume "--fixture" as the corpus directory; corpus
|
|
// falls back to its default and --fixture is still parsed on the next loop.
|
|
const parsed = parseArgs(['--corpus', '--fixture', 'x']);
|
|
expect(parsed.corpus).toBe('test/fixtures/corpus');
|
|
expect(parsed.fixture).toBe('x');
|
|
});
|
|
|
|
it('--corpus uses the default dir when it is the LAST token (no lookahead value)', () => {
|
|
expect(parseArgs(['--corpus'])).toEqual({ corpus: 'test/fixtures/corpus' });
|
|
});
|
|
|
|
it('a trailing --fixture with no value consumes undefined (off-by-one argv[++i])', () => {
|
|
// `argv[++i]` reads past the end -> undefined; the loop then terminates.
|
|
expect(parseArgs(['--fixture'])).toEqual({ fixture: undefined });
|
|
});
|
|
|
|
it('parses multiple flags together (page then a defaulted corpus)', () => {
|
|
const parsed = parseArgs(['--page', 'p-1', '--corpus']);
|
|
expect(parsed.page).toBe('p-1');
|
|
expect(parsed.corpus).toBe('test/fixtures/corpus');
|
|
});
|
|
});
|