forked from johannesjo/parallel-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpty.test.ts
More file actions
31 lines (25 loc) · 1.04 KB
/
pty.test.ts
File metadata and controls
31 lines (25 loc) · 1.04 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
import { describe, it, expect } from 'vitest';
import { validateCommand } from './pty.js';
describe('validateCommand', () => {
it('does not throw for a command found in PATH', () => {
// /bin/sh always exists on macOS/Linux
expect(() => validateCommand('/bin/sh')).not.toThrow();
});
it('throws a descriptive error for a missing command', () => {
expect(() => validateCommand('nonexistent-binary-xyz')).toThrow(/not found in PATH/);
});
it('throws a descriptive error naming the command', () => {
expect(() => validateCommand('nonexistent-binary-xyz')).toThrow(/nonexistent-binary-xyz/);
});
it('throws for a nonexistent absolute path', () => {
expect(() => validateCommand('/nonexistent/path/binary')).toThrow(
/not found or not executable/,
);
});
it('throws for an empty command string', () => {
expect(() => validateCommand('')).toThrow(/must not be empty/);
});
it('throws for a whitespace-only command string', () => {
expect(() => validateCommand(' ')).toThrow(/must not be empty/);
});
});