-
Notifications
You must be signed in to change notification settings - Fork 4
/
cli.test.js
121 lines (112 loc) Β· 7.78 KB
/
cli.test.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const child_process = require('child_process')
const fixtures = require('./__fixtures__')
let krasivorcContents = undefined
function callCLI (...args) {
const result = child_process.spawnSync(
'./cli.mock.js',
args,
{
env: {
...process.env,
KRASIVORC_CONTENTS: krasivorcContents
}
})
if (result.status === 0) {
return result.stdout.toString() // stdout buffer to string
}
return {
status: result.status,
stdout: result.stdout.toString()
}
}
describe('cli', () => {
beforeEach(() => {
krasivorcContents = undefined
})
it('works', () => {
expect(callCLI('lol', 'x', '~')).toBe(
[
'x~~~~~~xxx~~x~~~~',
'x~~~~~x~~~x~x~~~~',
'x~~~~~x~~~x~x~~~~',
'x~~~~~x~~~x~x~~~~',
'x~~~~~x~~~x~x~~~~',
'x~~~~~x~~~x~x~~~~',
'xxxxx~~xxx~~xxxxx',
''
].join('\n')
)
})
it('passes options correctly', () => {
expect(callCLI('lol', ':no_good:', ':wave:', '--short-emoji')).toBe(
[
'π
πππππππ
π
π
πππ
ππππ',
'π
ππππππ
ππππ
ππ
ππππ',
'π
ππππππ
ππππ
ππ
ππππ',
'π
ππππππ
ππππ
ππ
ππππ',
'π
ππππππ
ππππ
ππ
ππππ',
'π
ππππππ
ππππ
ππ
ππππ',
'π
π
π
π
π
πππ
π
π
πππ
π
π
π
π
',
''
].join('\n')
)
expect(callCLI('lol', ':no_good:', ':wave:', '--no-short-emoji')).toBe(
[
':no_good::wave::wave::wave::wave::wave::wave::no_good::no_good::no_good::wave::wave::no_good::wave::wave::wave::wave:',
':no_good::wave::wave::wave::wave::wave::no_good::wave::wave::wave::no_good::wave::no_good::wave::wave::wave::wave:',
':no_good::wave::wave::wave::wave::wave::no_good::wave::wave::wave::no_good::wave::no_good::wave::wave::wave::wave:',
':no_good::wave::wave::wave::wave::wave::no_good::wave::wave::wave::no_good::wave::no_good::wave::wave::wave::wave:',
':no_good::wave::wave::wave::wave::wave::no_good::wave::wave::wave::no_good::wave::no_good::wave::wave::wave::wave:',
':no_good::wave::wave::wave::wave::wave::no_good::wave::wave::wave::no_good::wave::no_good::wave::wave::wave::wave:',
':no_good::no_good::no_good::no_good::no_good::wave::wave::no_good::no_good::no_good::wave::wave::no_good::no_good::no_good::no_good::no_good:',
''
].join('\n')
)
expect(callCLI('lol', ':no_good:', ':wave:', '--skin-tone=2')).toBe(
[
'π
π»ππ»ππ»ππ»ππ»ππ»ππ»π
π»π
π»π
π»ππ»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»π
π»π
π»π
π»π
π»ππ»ππ»π
π»π
π»π
π»ππ»ππ»π
π»π
π»π
π»π
π»π
π»',
''
].join('\n')
)
})
it('takes settings from ~/.krasivorc', () => {
krasivorcContents = fixtures.withSkinTone
expect(callCLI('lol', ':no_good:', ':wave:')).toBe(
[
'π
π»ππ»ππ»ππ»ππ»ππ»ππ»π
π»π
π»π
π»ππ»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»ππ»ππ»ππ»ππ»ππ»π
π»ππ»ππ»ππ»π
π»ππ»π
π»ππ»ππ»ππ»ππ»',
'π
π»π
π»π
π»π
π»π
π»ππ»ππ»π
π»π
π»π
π»ππ»ππ»π
π»π
π»π
π»π
π»π
π»',
''
].join('\n')
)
krasivorcContents = fixtures.withAllOptions
expect(callCLI('lol', ':no_good:', ':wave:')).toBe(
[
':no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2:',
':no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2:',
':no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2:',
':no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2:',
':no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2:',
':no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2:',
':no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::wave::skin-tone-2::wave::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2::no_good::skin-tone-2:',
''
].join('\n')
)
})
it('reports an error when ~/.krasivorc contains invalid YAML', () => {
krasivorcContents = fixtures.invalid
const result = callCLI('lol', ':no_good:', ':wave:')
expect(result.status).not.toBe(0)
expect(result.stdout).toBe(' ERROR .krasivorc is not a valid YAML file\n')
})
})