@@ -53,7 +53,7 @@ test('does not prepend newline if first string is greater than "cols"', t => {
53
53
test ( 'breaks strings longer than "cols" characters' , t => {
54
54
const res5 = m ( fixture , 5 , { hard : true } ) ;
55
55
56
- t . is ( res5 , 'The\nquick\nbrown\n\u001B[31mfox\u001B[39m\n\u001B[31mjumpe\u001B[39m\n\u001B[31md \u001B[39m\n\u001B[31mover\u001B[39m\n\u001B[31m\u001B[39mthe\nlazy\n\u001B[32mdog\u001B[39m\n\u001B[32mand\u001B[39m\n\u001B[32mthen\u001B[39m\n\u001B[32mran\u001B[39m\n\u001B[32maway\u001B[39m\n\u001B[32mwith\u001B[39m\n\u001B[32mthe\u001B[39m\n\u001B[32munico\u001B[39m\n\u001B[32mrn.\u001B[39m' ) ;
56
+ t . is ( res5 , 'The\nquick\nbrown\n\u001B[31mfox j \u001B[39m\n\u001B[31mumped \u001B[39m\n\u001B[31mover\u001B[39m\n\u001B[31m\u001B[39mthe\nlazy\n\u001B[32mdog\u001B[39m\n\u001B[32mand\u001B[39m\n\u001B[32mthen\u001B[39m\n\u001B[32mran\u001B[39m\n\u001B[32maway\u001B[39m\n\u001B[32mwith\u001B[39m\n\u001B[32mthe\u001B[39m\n\u001B[32munico\u001B[39m\n\u001B[32mrn.\u001B[39m' ) ;
57
57
t . true ( stripAnsi ( res5 ) . split ( '\n' ) . every ( x => x . length <= 5 ) ) ;
58
58
} ) ;
59
59
@@ -113,3 +113,32 @@ test('supports unicode surrogate pairs', t => {
113
113
t . is ( m ( 'a\uD83C\uDE00bc' , 2 , { hard : true } ) , 'a\n\uD83C\uDE00\nbc' ) ;
114
114
t . is ( m ( 'a\uD83C\uDE00bc\uD83C\uDE00d\uD83C\uDE00' , 2 , { hard : true } ) , 'a\n\uD83C\uDE00\nbc\n\uD83C\uDE00\nd\n\uD83C\uDE00' ) ;
115
115
} ) ;
116
+
117
+ test ( '#23, properly wraps whitespace with no trimming' , t => {
118
+ t . is ( m ( ' ' , 2 , { trim : false } ) , ' \n ' ) ;
119
+ t . is ( m ( ' ' , 2 , { trim : false , hard : true } ) , ' \n ' ) ;
120
+ } ) ;
121
+
122
+ test ( '#24, trims leading and trailing whitespace only on actual wrapped lines and only with trimming' , t => {
123
+ t . is ( m ( ' foo bar ' , 6 ) , 'foo\nbar' ) ;
124
+ t . is ( m ( ' foo bar ' , 42 ) , 'foo bar' ) ;
125
+ t . is ( m ( ' foo bar ' , 42 , { trim : false } ) , ' foo bar ' ) ;
126
+ } ) ;
127
+
128
+ test ( '#25, properly wraps whitespace between words with no trimming' , t => {
129
+ t . is ( m ( 'foo bar' , 3 ) , 'foo\nbar' ) ;
130
+ t . is ( m ( 'foo bar' , 3 , { hard : true } ) , 'foo\nbar' ) ;
131
+ t . is ( m ( 'foo bar' , 3 , { trim : false } ) , 'foo\n \nbar' ) ;
132
+ t . is ( m ( 'foo bar' , 3 , { trim : false , hard : true } ) , 'foo\n \nbar' ) ;
133
+ } ) ;
134
+
135
+ test ( '#26, does not multiplicate leading spaces with no trimming' , t => {
136
+ t . is ( m ( ' a ' , 10 , { trim : false } ) , ' a ' ) ;
137
+ t . is ( m ( ' a ' , 10 , { trim : false } ) , ' a ' ) ;
138
+ } ) ;
139
+
140
+ test ( '#27, does not remove spaces in line with ansi escapes when no trimming' , t => {
141
+ t . is ( m ( chalk . bgGreen ( ` ${ chalk . black ( 'OK' ) } ` ) , 100 , { trim : false } ) , chalk . bgGreen ( ` ${ chalk . black ( 'OK' ) } ` ) ) ;
142
+ t . is ( m ( chalk . bgGreen ( ` ${ chalk . black ( 'OK' ) } ` ) , 100 , { trim : false } ) , chalk . bgGreen ( ` ${ chalk . black ( 'OK' ) } ` ) ) ;
143
+ t . is ( m ( chalk . bgGreen ( ' hello ' ) , 10 , { hard : true , trim : false } ) , chalk . bgGreen ( ' hello ' ) ) ;
144
+ } ) ;
0 commit comments