-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
add-command-prefix.spec.ts
48 lines (44 loc) · 1.29 KB
/
add-command-prefix.spec.ts
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
import { addPrefixToLines } from './add-command-prefix';
const stripAnsi = require('strip-ansi');
describe('addPrefixToLines', () => {
it('should add project name as a prefix', () => {
const prefixed = addPrefixToLines('myproj', ['one', 'two', 'three']);
expect(prefixed.map(stripAnsi)).toEqual([
'[myproj ] one',
'[myproj ] two',
'[myproj ] three',
]);
});
it('should handle project names which length = 15', () => {
const prefixed = addPrefixToLines('123456789012345', [
'one',
'two',
'three',
]);
expect(prefixed.map(stripAnsi)).toEqual([
'[123456789012345] one',
'[123456789012345] two',
'[123456789012345] three',
]);
});
it('should handle long project names', () => {
const prefixed = addPrefixToLines('12345678901234567890', [
'one',
'two',
'three',
]);
expect(prefixed.map(stripAnsi)).toEqual([
'[...901234567890] one',
'[...901234567890] two',
'[...901234567890] three',
]);
});
it('should not prefix last empty line', () => {
const prefixed = addPrefixToLines('myproj', ['one', 'two', '']);
expect(prefixed.map(stripAnsi)).toEqual([
'[myproj ] one',
'[myproj ] two',
'',
]);
});
});