import { parseCliOptions } from './run-competition-domain'; describe('competition domain migration CLI', () => { const originalNodeEnv = process.env.NODE_ENV; beforeEach(() => { process.env.NODE_ENV = 'dev'; }); afterAll(() => { process.env.NODE_ENV = originalNodeEnv; }); it('ignores pnpm standalone separators before dry-run and apply options', () => { expect(parseCliOptions(['--', '--dry-run'])).toMatchObject({ dryRun: true, help: false, nodeEnv: 'dev', }); expect(parseCliOptions(['--', '--apply'])).toMatchObject({ dryRun: false, help: false, nodeEnv: 'dev', }); }); it('recognizes help after a pnpm standalone separator without exiting', () => { expect(parseCliOptions(['--', '--help'])).toMatchObject({ dryRun: true, help: true, nodeEnv: 'dev', }); }); it('accepts an explicit Match cursor for limited-run recovery', () => { expect( parseCliOptions([ '--apply', '--limit=25', '--after', '66a000000000000000000123', ]), ).toMatchObject({ dryRun: false, limit: 25, afterMatchId: '66a000000000000000000123', }); expect(() => parseCliOptions(['--after', 'not-an-object-id'])).toThrow( '--after requires a 24-character hexadecimal Match ObjectId.', ); }); });