@@ -41,6 +41,8 @@ describe('cli', () => {
41
41
42
42
describe ( 'spinners' , ( ) => {
43
43
beforeEach ( ( ) => {
44
+ stream = new LogStream ( ) ;
45
+ cli = new CLI ( stream ) ;
44
46
cli . startSpinner ( 'foo' ) ;
45
47
} ) ;
46
48
@@ -59,20 +61,34 @@ describe('cli', () => {
59
61
} ) ;
60
62
61
63
describe ( 'write' , ( ) => {
64
+ beforeEach ( ( ) => {
65
+ stream = new LogStream ( ) ;
66
+ cli = new CLI ( stream ) ;
67
+ } ) ;
62
68
it ( 'should write in stream' , ( ) => {
69
+ const stream = new LogStream ( ) ;
70
+ const cli = new CLI ( stream ) ;
63
71
cli . write ( 'Getting commits...' ) ;
64
- assert . strictEqual ( logResult ( ) , 'Getting commits...' ) ;
72
+ assert . strictEqual ( strip ( stream . toString ( ) ) , 'Getting commits...' ) ;
65
73
} ) ;
66
74
} ) ;
67
75
68
76
describe ( 'log' , ( ) => {
77
+ beforeEach ( ( ) => {
78
+ stream = new LogStream ( ) ;
79
+ cli = new CLI ( stream ) ;
80
+ } ) ;
69
81
it ( 'should write in stream' , ( ) => {
70
82
cli . log ( 'Getting commits...' ) ;
71
83
assert . strictEqual ( logResult ( ) , 'Getting commits...\n' ) ;
72
84
} ) ;
73
85
} ) ;
74
86
75
87
describe ( 'table' , ( ) => {
88
+ beforeEach ( ( ) => {
89
+ stream = new LogStream ( ) ;
90
+ cli = new CLI ( stream ) ;
91
+ } ) ;
76
92
it ( 'should print the first element with bold style and padding' , ( ) => {
77
93
cli . table ( 'Title' , 'description' ) ;
78
94
assert . strictEqual ( logResult ( ) ,
@@ -81,6 +97,10 @@ describe('cli', () => {
81
97
} ) ;
82
98
83
99
describe ( 'separator' , ( ) => {
100
+ beforeEach ( ( ) => {
101
+ stream = new LogStream ( ) ;
102
+ cli = new CLI ( stream ) ;
103
+ } ) ;
84
104
it ( 'should print a separator line with the specified text' , ( ) => {
85
105
cli . separator ( 'Separator' ) ;
86
106
assert . strictEqual (
@@ -106,6 +126,10 @@ describe('cli', () => {
106
126
} ) ;
107
127
108
128
describe ( 'ok' , ( ) => {
129
+ beforeEach ( ( ) => {
130
+ stream = new LogStream ( ) ;
131
+ cli = new CLI ( stream ) ;
132
+ } ) ;
109
133
it ( 'should print a success message' , ( ) => {
110
134
cli . ok ( 'Perfect!' ) ;
111
135
assert . strictEqual ( logResult ( ) , ` ${ success } Perfect!\n` ) ;
@@ -119,6 +143,10 @@ describe('cli', () => {
119
143
} ) ;
120
144
121
145
describe ( 'warn' , ( ) => {
146
+ beforeEach ( ( ) => {
147
+ stream = new LogStream ( ) ;
148
+ cli = new CLI ( stream ) ;
149
+ } ) ;
122
150
it ( 'should print a warning message' , ( ) => {
123
151
cli . warn ( 'Warning!' ) ;
124
152
assert . strictEqual ( logResult ( ) , ` ${ warning } Warning!\n` ) ;
@@ -132,6 +160,10 @@ describe('cli', () => {
132
160
} ) ;
133
161
134
162
describe ( 'info' , ( ) => {
163
+ beforeEach ( ( ) => {
164
+ stream = new LogStream ( ) ;
165
+ cli = new CLI ( stream ) ;
166
+ } ) ;
135
167
it ( 'should print an info message' , ( ) => {
136
168
cli . info ( 'Info!' ) ;
137
169
assert . strictEqual ( logResult ( ) , ` ${ info } Info!\n` ) ;
@@ -144,6 +176,10 @@ describe('cli', () => {
144
176
} ) ;
145
177
146
178
describe ( 'error' , ( ) => {
179
+ beforeEach ( ( ) => {
180
+ stream = new LogStream ( ) ;
181
+ cli = new CLI ( stream ) ;
182
+ } ) ;
147
183
it ( 'should print an error message' , ( ) => {
148
184
cli . error ( 'Error!' ) ;
149
185
assert . strictEqual ( logResult ( ) , ` ${ error } Error!\n` ) ;
@@ -184,6 +220,7 @@ describe('cli', () => {
184
220
questionType : cli . QUESTION_TYPE . INPUT
185
221
} ) ;
186
222
assert . strictEqual ( cli . spinner . isSpinning , true ) ;
223
+ cli . stopSpinner ( 'foo' ) ;
187
224
} ) ;
188
225
} ) ;
189
226
0 commit comments