@@ -10,6 +10,15 @@ var cliui = require('../')
10
10
var stripAnsi = require ( 'strip-ansi' )
11
11
12
12
describe ( 'cliui' , function ( ) {
13
+ describe ( 'resetOutput' , function ( ) {
14
+ it ( 'should set lines to empty' , function ( ) {
15
+ var ui = cliui ( )
16
+ ui . div ( 'i am a value that would be in a line' )
17
+ ui . resetOutput ( )
18
+ ui . toString ( ) . length . should . be . equal ( 0 )
19
+ } )
20
+ } )
21
+
13
22
describe ( 'div' , function ( ) {
14
23
it ( "wraps text at 'width' if a single column is given" , function ( ) {
15
24
var ui = cliui ( {
@@ -29,7 +38,7 @@ describe('cliui', function () {
29
38
} )
30
39
31
40
ui . div (
32
- { text : 'i am a string that should be wrapped' , width : 15 } ,
41
+ { text : 'i am a string that should be wrapped' , width : 15 } ,
33
42
'i am a second string that should be wrapped' ,
34
43
'i am a third string that should be wrapped'
35
44
)
@@ -82,7 +91,7 @@ describe('cliui', function () {
82
91
var ui = cliui ( {
83
92
width : 40
84
93
} )
85
- var widths = ui . _columnWidths ( [ { width : 20 } , { } , { } ] )
94
+ var widths = ui . _columnWidths ( [ { width : 20 } , { } , { } ] )
86
95
87
96
widths [ 0 ] . should . equal ( 20 )
88
97
widths [ 1 ] . should . equal ( 10 )
@@ -93,7 +102,7 @@ describe('cliui', function () {
93
102
var ui = cliui ( {
94
103
width : 40
95
104
} )
96
- var widths = ui . _columnWidths ( [ { } , { width : 10 } , { } ] )
105
+ var widths = ui . _columnWidths ( [ { } , { width : 10 } , { } ] )
97
106
98
107
widths [ 0 ] . should . equal ( 15 )
99
108
widths [ 1 ] . should . equal ( 10 )
@@ -104,7 +113,7 @@ describe('cliui', function () {
104
113
var ui = cliui ( {
105
114
width : 40
106
115
} )
107
- var widths = ui . _columnWidths ( [ { width : 20 } , { width : 12 } , { } ] )
116
+ var widths = ui . _columnWidths ( [ { width : 20 } , { width : 12 } , { } ] )
108
117
109
118
widths [ 0 ] . should . equal ( 20 )
110
119
widths [ 1 ] . should . equal ( 12 )
@@ -115,7 +124,7 @@ describe('cliui', function () {
115
124
var ui = cliui ( {
116
125
width : 40
117
126
} )
118
- var widths = ui . _columnWidths ( [ { width : 30 } , { width : 30 } , { padding : [ 0 , 2 , 0 , 1 ] } ] )
127
+ var widths = ui . _columnWidths ( [ { width : 30 } , { width : 30 } , { padding : [ 0 , 2 , 0 , 1 ] } ] )
119
128
120
129
widths [ 0 ] . should . equal ( 30 )
121
130
widths [ 1 ] . should . equal ( 30 )
@@ -131,7 +140,7 @@ describe('cliui', function () {
131
140
132
141
ui . div (
133
142
'i am a string' ,
134
- { text : 'i am a second string' , align : 'right' } ,
143
+ { text : 'i am a second string' , align : 'right' } ,
135
144
'i am a third string that should be wrapped'
136
145
)
137
146
@@ -153,7 +162,7 @@ describe('cliui', function () {
153
162
154
163
ui . div (
155
164
'i am a string' ,
156
- { text : 'i am a second string' , align : 'center' , padding : [ 0 , 2 , 0 , 2 ] } ,
165
+ { text : 'i am a second string' , align : 'center' , padding : [ 0 , 2 , 0 , 2 ] } ,
157
166
'i am a third string that should be wrapped'
158
167
)
159
168
@@ -175,9 +184,9 @@ describe('cliui', function () {
175
184
} )
176
185
177
186
ui . div (
178
- { text : 'i have padding on my left' , padding : [ 0 , 0 , 0 , 4 ] } ,
179
- { text : 'i have padding on my right' , padding : [ 0 , 2 , 0 , 0 ] , align : 'center' } ,
180
- { text : 'i have no padding' , padding : [ 0 , 0 , 0 , 0 ] }
187
+ { text : 'i have padding on my left' , padding : [ 0 , 0 , 0 , 4 ] } ,
188
+ { text : 'i have padding on my right' , padding : [ 0 , 2 , 0 , 0 ] , align : 'center' } ,
189
+ { text : 'i have no padding' , padding : [ 0 , 0 , 0 , 0 ] }
181
190
)
182
191
183
192
// it should add left/right padding to columns.
@@ -198,8 +207,8 @@ describe('cliui', function () {
198
207
199
208
ui . div (
200
209
'i am a string' ,
201
- { text : 'i am a second string' , padding : [ 2 , 0 , 0 , 0 ] } ,
202
- { text : 'i am a third string that should be wrapped' , padding : [ 0 , 0 , 1 , 0 ] }
210
+ { text : 'i am a second string' , padding : [ 2 , 0 , 0 , 0 ] } ,
211
+ { text : 'i am a third string that should be wrapped' , padding : [ 0 , 0 , 1 , 0 ] }
203
212
)
204
213
205
214
// it should add top/bottom padding to second
@@ -239,8 +248,8 @@ describe('cliui', function () {
239
248
} )
240
249
241
250
ui . div (
242
- { text : 'i am a first string' , padding : [ 0 , 0 , 0 , 0 ] , border : true } ,
243
- { text : 'i am a second string' , padding : [ 1 , 0 , 0 , 0 ] , border : true }
251
+ { text : 'i am a first string' , padding : [ 0 , 0 , 0 , 0 ] , border : true } ,
252
+ { text : 'i am a second string' , padding : [ 1 , 0 , 0 , 0 ] , border : true }
244
253
)
245
254
246
255
var expected = [
@@ -262,9 +271,9 @@ describe('cliui', function () {
262
271
} )
263
272
264
273
ui . div (
265
- { text : 'i am a string' , padding : [ 0 , 1 , 0 , 0 ] } ,
266
- { text : 'i am a second string' , padding : [ 0 , 2 , 0 , 0 ] } ,
267
- { text : 'i am a third string that should not be wrapped' , padding : [ 0 , 0 , 0 , 2 ] }
274
+ { text : 'i am a string' , padding : [ 0 , 1 , 0 , 0 ] } ,
275
+ { text : 'i am a second string' , padding : [ 0 , 2 , 0 , 0 ] } ,
276
+ { text : 'i am a third string that should not be wrapped' , padding : [ 0 , 0 , 0 , 2 ] }
268
277
)
269
278
270
279
ui . toString ( ) . should . equal ( 'i am a string i am a second string i am a third string that should not be wrapped' )
@@ -278,11 +287,11 @@ describe('cliui', function () {
278
287
} )
279
288
280
289
ui . span (
281
- { text : 'i am a string that will be wrapped' , width : 30 }
290
+ { text : 'i am a string that will be wrapped' , width : 30 }
282
291
)
283
292
284
293
ui . div (
285
- { text : ' [required] [default: 99]' , align : 'right' }
294
+ { text : ' [required] [default: 99]' , align : 'right' }
286
295
)
287
296
288
297
var expected = [
@@ -299,11 +308,11 @@ describe('cliui', function () {
299
308
} )
300
309
301
310
ui . span (
302
- { text : 'i am a string that will be wrapped' , width : 30 }
311
+ { text : 'i am a string that will be wrapped' , width : 30 }
303
312
)
304
313
305
314
ui . div (
306
- { text : 'i am a second row' , align : 'left' }
315
+ { text : 'i am a second row' , align : 'left' }
307
316
)
308
317
309
318
var expected = [
@@ -322,11 +331,11 @@ describe('cliui', function () {
322
331
} )
323
332
324
333
ui . span (
325
- { text : 'i am a string that will be wrapped' , width : 30 }
334
+ { text : 'i am a string that will be wrapped' , width : 30 }
326
335
)
327
336
328
337
ui . div (
329
- { text : 'i am a second row' , align : 'left' , padding : [ 0 , 0 , 0 , 3 ] }
338
+ { text : 'i am a second row' , align : 'left' , padding : [ 0 , 0 , 0 , 3 ] }
330
339
)
331
340
332
341
ui . div ( 'a third line' )
@@ -345,11 +354,11 @@ describe('cliui', function () {
345
354
} )
346
355
347
356
ui . span (
348
- { text : chalk . green ( 'i am a string that will be wrapped' ) , width : 30 }
357
+ { text : chalk . green ( 'i am a string that will be wrapped' ) , width : 30 }
349
358
)
350
359
351
360
ui . div (
352
- { text : chalk . blue ( ' [required] [default: 99]' ) , align : 'right' }
361
+ { text : chalk . blue ( ' [required] [default: 99]' ) , align : 'right' }
353
362
)
354
363
355
364
var expected = [
0 commit comments