Repository navigation
Expand file tree
/
Copy pathlaunch.test.js
More file actions
50 lines (42 loc) · 1.51 KB
/
Copy pathlaunch.test.js
File metadata and controls
50 lines (42 loc) · 1.51 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
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const { copilotSpawnConfig } = require('../lib/launch');
const id = '61a85c21-6fdc-4e9b-b481-d502247d32a0';
test('copilotSpawnConfig uses shell:false on non-Windows', () => {
const launch = copilotSpawnConfig({ id, cwd: '/tmp/repo', platform: 'darwin' });
assert.equal(launch.command, 'copilot');
assert.deepEqual(launch.args, ['--resume', id]);
assert.deepEqual(launch.options, {
stdio: 'inherit',
shell: false,
cwd: '/tmp/repo',
});
});
test('copilotSpawnConfig avoids shell:true with args on Windows', () => {
const launch = copilotSpawnConfig({
id,
cwd: 'C:\\repo',
platform: 'win32',
comspec: 'C:\\Windows\\System32\\cmd.exe',
});
assert.equal(launch.command, 'C:\\Windows\\System32\\cmd.exe');
assert.deepEqual(launch.args, ['/d', '/s', '/c', 'copilot', '--resume', id]);
assert.deepEqual(launch.options, {
stdio: 'inherit',
shell: false,
cwd: 'C:\\repo',
});
});
test('copilotSpawnConfig starts a new Windows session without resume args', () => {
const launch = copilotSpawnConfig({ platform: 'win32', comspec: null });
assert.equal(launch.command, 'cmd.exe');
assert.deepEqual(launch.args, ['/d', '/s', '/c', 'copilot']);
assert.equal(launch.options.shell, false);
});
test('copilotSpawnConfig rejects unsafe resume ids', () => {
assert.throws(
() => copilotSpawnConfig({ id: 'abc & calc.exe', platform: 'win32' }),
{ code: 'INVALID_SESSION_ID' },
);
});