mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-15 20:20:09 +00:00
- add dependency injection to export-command, binary-manager, codex-plan-compatibility, config-command, and usage-syncer - override process.exit in api-export test to prevent silent termination in Bun's parallel test runner - harden test-environment bootstrap with process.env isolation - fix auth middleware to avoid config upgrade during checks
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
import { tmpdir } from 'os';
|
|
import { join, resolve } from 'path';
|
|
import { extractOption } from '../../../src/commands/arg-extractor';
|
|
|
|
describe('api export command', () => {
|
|
it('accepts dash-prefixed output paths via extractOption', () => {
|
|
const result = extractOption(['profile-a', '--out', '--snapshot.json'], ['--out'], {
|
|
allowDashValue: true,
|
|
allowLongDashValue: true,
|
|
knownFlags: ['--out', '--include-secrets'],
|
|
});
|
|
|
|
expect(result.found).toBe(true);
|
|
expect(result.missingValue).toBe(false);
|
|
expect(result.value).toBe('--snapshot.json');
|
|
expect(result.remainingArgs).toEqual(['profile-a']);
|
|
});
|
|
|
|
it('writes dash-prefixed filenames to disk', () => {
|
|
const dir = mkdtempSync(join(tmpdir(), 'ccs-api-export-test-'));
|
|
try {
|
|
const outputPath = resolve(dir, '--snapshot.json');
|
|
const bundle = { profile: { name: 'profile-a' } };
|
|
writeFileSync(outputPath, JSON.stringify(bundle, null, 2) + '\n', 'utf8');
|
|
|
|
expect(existsSync(outputPath)).toBe(true);
|
|
expect(readFileSync(outputPath, 'utf8')).toContain('"name": "profile-a"');
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|