-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathformat-command-log.integration.test.ts
More file actions
61 lines (50 loc) · 1.78 KB
/
format-command-log.integration.test.ts
File metadata and controls
61 lines (50 loc) · 1.78 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
56
57
58
59
60
61
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { removeColorCodes } from '@code-pushup/test-utils';
import { formatCommandLog } from './format-command-log.js';
describe('formatCommandLog', () => {
it('should format simple command', () => {
const result = removeColorCodes(
formatCommandLog('npx', ['command', '--verbose']),
);
expect(result).toBe('$ npx command --verbose');
});
it('should format simple command with explicit process.cwd()', () => {
const result = removeColorCodes(
formatCommandLog('npx', ['command', '--verbose'], process.cwd()),
);
expect(result).toBe('$ npx command --verbose');
});
it('should format simple command with relative cwd', () => {
const result = removeColorCodes(
formatCommandLog('npx', ['command', '--verbose'], './wololo'),
);
expect(result).toBe(`wololo $ npx command --verbose`);
});
it('should format simple command with absolute non-current path converted to relative', () => {
const result = removeColorCodes(
formatCommandLog(
'npx',
['command', '--verbose'],
path.join(process.cwd(), 'tmp'),
),
);
expect(result).toBe('tmp $ npx command --verbose');
});
it('should format simple command with relative cwd in parent folder', () => {
const result = removeColorCodes(
formatCommandLog('npx', ['command', '--verbose'], '..'),
);
expect(result).toBe(`.. $ npx command --verbose`);
});
it('should format simple command using relative path to parent directory', () => {
const result = removeColorCodes(
formatCommandLog(
'npx',
['command', '--verbose'],
path.dirname(process.cwd()),
),
);
expect(result).toBe('.. $ npx command --verbose');
});
});