Files
gstack/test/jargon-list.test.ts
T
Garry Tan 00a7a65026 test: V1 gate coverage — writing-style resolver + config + jargon + migration + dormancy
Six new gate-tier test files:

- test/writing-style-resolver.test.ts — asserts Writing Style section
  is injected into tier-≥2 preamble, all 6 rules present, jargon list
  inlined, terse-mode gate condition present, Codex output uses
  \$GSTACK_BIN (not ~/.claude/), tier-1 does NOT get the section,
  migration-prompt block present.

- test/explain-level-config.test.ts — gstack-config set/get round-trip
  for default + terse, unknown-value warns + defaults to default,
  header documents the key, round-trip across set→set→get.

- test/jargon-list.test.ts — shape + ~50 terms + no duplicates
  (case-insensitive) + includes canonical high-signal terms.

- test/v0-dormancy.test.ts — 5D dimension names + archetype names
  forbidden in default-mode tier-≥2 SKILL.md output, except for
  plan-tune and office-hours where they're load-bearing.

- test/readme-throughput.test.ts — script replaces anchor with number
  on happy path, writes PENDING marker when JSON missing, CI gate
  asserts committed README contains no PENDING string.

- test/upgrade-migration-v1.test.ts — fresh run writes pending flag,
  idempotent after user-answered, pre-existing explain_level counts
  as answered.

All 95 V1 test-expect() calls pass. Full suite: 0 failures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 11:39:24 +08:00

62 lines
2.3 KiB
TypeScript

/**
* scripts/jargon-list.json — shape + content validation.
*
* This file is baked into generated SKILL.md prose at gen-skill-docs time.
* Tests assert: valid JSON, expected shape, ~50 terms, no duplicates, no empty strings.
*/
import { describe, test, expect } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
const ROOT = path.resolve(import.meta.dir, '..');
const JARGON_PATH = path.join(ROOT, 'scripts', 'jargon-list.json');
describe('jargon-list.json', () => {
test('file exists + parses as JSON', () => {
expect(fs.existsSync(JARGON_PATH)).toBe(true);
expect(() => JSON.parse(fs.readFileSync(JARGON_PATH, 'utf-8'))).not.toThrow();
});
test('has expected top-level shape', () => {
const data = JSON.parse(fs.readFileSync(JARGON_PATH, 'utf-8'));
expect(data).toHaveProperty('version');
expect(data).toHaveProperty('description');
expect(data).toHaveProperty('terms');
expect(Array.isArray(data.terms)).toBe(true);
expect(typeof data.version).toBe('number');
});
test('contains ~50 terms (±20 tolerance)', () => {
const data = JSON.parse(fs.readFileSync(JARGON_PATH, 'utf-8'));
expect(data.terms.length).toBeGreaterThanOrEqual(30);
expect(data.terms.length).toBeLessThanOrEqual(80);
});
test('all terms are non-empty strings', () => {
const data = JSON.parse(fs.readFileSync(JARGON_PATH, 'utf-8'));
for (const t of data.terms) {
expect(typeof t).toBe('string');
expect(t.trim().length).toBeGreaterThan(0);
}
});
test('no duplicate terms (case-insensitive)', () => {
const data = JSON.parse(fs.readFileSync(JARGON_PATH, 'utf-8'));
const seen = new Set<string>();
for (const t of data.terms) {
const key = t.toLowerCase();
expect(seen.has(key)).toBe(false);
seen.add(key);
}
});
test('includes common high-signal terms', () => {
const data = JSON.parse(fs.readFileSync(JARGON_PATH, 'utf-8'));
const terms = new Set(data.terms.map((t: string) => t.toLowerCase()));
// Sanity: the list should include some canonical gstack-review jargon
expect(terms.has('idempotent') || terms.has('idempotency')).toBe(true);
expect(terms.has('race condition')).toBe(true);
expect(terms.has('n+1') || terms.has('n+1 query')).toBe(true);
});
});