-
-
Notifications
You must be signed in to change notification settings - Fork 415
Expand file tree
/
Copy pathcodexLocal.test.ts
More file actions
55 lines (45 loc) · 2.22 KB
/
codexLocal.test.ts
File metadata and controls
55 lines (45 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { describe, it, expect, vi } from 'vitest';
vi.mock('@/ui/logger', () => ({
logger: {
debug: () => {},
warn: () => {}
}
}));
import { filterManagedSessionSubcommand } from './codexLocal';
describe('filterManagedSessionSubcommand', () => {
it('returns empty array unchanged', () => {
expect(filterManagedSessionSubcommand([])).toEqual([]);
});
it('passes through args when first arg is not resume', () => {
expect(filterManagedSessionSubcommand(['--model', 'gpt-4'])).toEqual(['--model', 'gpt-4']);
expect(filterManagedSessionSubcommand(['--sandbox', 'read-only'])).toEqual(['--sandbox', 'read-only']);
});
it('filters resume subcommand with session ID', () => {
expect(filterManagedSessionSubcommand(['resume', 'abc-123'])).toEqual([]);
expect(filterManagedSessionSubcommand(['resume', 'abc-123', '--model', 'gpt-4']))
.toEqual(['--model', 'gpt-4']);
});
it('filters resume subcommand without session ID', () => {
expect(filterManagedSessionSubcommand(['resume'])).toEqual([]);
expect(filterManagedSessionSubcommand(['resume', '--model', 'gpt-4']))
.toEqual(['--model', 'gpt-4']);
});
it('filters fork subcommand with session ID', () => {
expect(filterManagedSessionSubcommand(['fork', 'abc-123'])).toEqual([]);
expect(filterManagedSessionSubcommand(['fork', 'abc-123', '--model', 'gpt-4']))
.toEqual(['--model', 'gpt-4']);
});
it('does not filter resume when it appears as flag value', () => {
// --name resume should pass through (resume is value, not subcommand)
expect(filterManagedSessionSubcommand(['--name', 'resume'])).toEqual(['--name', 'resume']);
});
it('does not filter resume in middle of args', () => {
// If resume appears after flags, it's not the subcommand position
expect(filterManagedSessionSubcommand(['--model', 'gpt-4', 'resume', '123']))
.toEqual(['--model', 'gpt-4', 'resume', '123']);
});
it('does not filter fork in middle of args', () => {
expect(filterManagedSessionSubcommand(['--model', 'gpt-4', 'fork', '123']))
.toEqual(['--model', 'gpt-4', 'fork', '123']);
});
});