| skipped 12 lines |
13 | 13 | | const test = RenderConsole( 'test', { |
14 | 14 | | align: 'left', |
15 | 15 | | colors: [], |
16 | | - | letterSpacing: 1, |
17 | | - | lineHeight: 1, |
| 16 | + | letterSpacing: 0, |
| 17 | + | lineHeight: 0, |
18 | 18 | | }, { width: 100, height: 10 } ); |
19 | 19 | | |
20 | 20 | | expect( test.output ).toEqual( ['test'] ); |
| skipped 5 lines |
26 | 26 | | const test = RenderConsole( 'x', { |
27 | 27 | | align: 'left', |
28 | 28 | | colors: [], |
29 | | - | letterSpacing: 1, |
30 | | - | lineHeight: 1, |
| 29 | + | letterSpacing: 0, |
| 30 | + | lineHeight: 0, |
31 | 31 | | }); |
32 | 32 | | |
33 | 33 | | expect( test.output ).toEqual( ['x'] ); |
| skipped 5 lines |
39 | 39 | | const test = RenderConsole( 'test|test', { |
40 | 40 | | align: 'left', |
41 | 41 | | colors: [], |
42 | | - | letterSpacing: 1, |
43 | | - | lineHeight: 1, |
| 42 | + | letterSpacing: 0, |
| 43 | + | lineHeight: 0, |
44 | 44 | | }, { width: 100, height: 10 } ); |
45 | 45 | | |
46 | 46 | | expect( test.output ).toEqual( ['test', 'test'] ); |
| skipped 5 lines |
52 | 52 | | const test = RenderConsole( 'this is a very long line to test multi lines', { |
53 | 53 | | align: 'left', |
54 | 54 | | colors: [], |
55 | | - | letterSpacing: 1, |
56 | | - | lineHeight: 1, |
| 55 | + | letterSpacing: 0, |
| 56 | + | lineHeight: 0, |
57 | 57 | | }, { width: 10, height: 10 } ); |
58 | 58 | | |
59 | | - | expect( test.output ).toEqual( ['this is a', 'very long', 'line to te', 'st multi l', 'ines'] ); |
| 59 | + | expect( test.output ).toEqual( ['this is a ', 'very long ', 'line to te', 'st multi l', 'ines'] ); |
60 | 60 | | expect( test.lines ).toEqual( 5 ); |
61 | 61 | | }); |
62 | 62 | | |
| skipped 2 lines |
65 | 65 | | const test = RenderConsole( 'center', { |
66 | 66 | | align: 'center', |
67 | 67 | | colors: [], |
68 | | - | letterSpacing: 1, |
69 | | - | lineHeight: 1, |
| 68 | + | letterSpacing: 0, |
| 69 | + | lineHeight: 0, |
70 | 70 | | }, { width: 10, height: 10 } ); |
71 | 71 | | |
72 | 72 | | expect( test.output ).toEqual( [' center'] ); |
| skipped 5 lines |
78 | 78 | | const test = RenderConsole( 'right', { |
79 | 79 | | align: 'right', |
80 | 80 | | colors: [], |
81 | | - | letterSpacing: 1, |
82 | | - | lineHeight: 1, |
| 81 | + | letterSpacing: 0, |
| 82 | + | lineHeight: 0, |
83 | 83 | | }, { width: 10, height: 10 } ); |
84 | 84 | | |
85 | 85 | | expect( test.output ).toEqual( [' right'] ); |
| skipped 6 lines |
92 | 92 | | align: 'left', |
93 | 93 | | colors: [], |
94 | 94 | | letterSpacing: 2, |
95 | | - | lineHeight: 1, |
| 95 | + | lineHeight: 0, |
96 | 96 | | }, { width: 10, height: 10 } ); |
97 | 97 | | |
98 | | - | expect( test1.output ).toEqual( ['t e x t'] ); |
| 98 | + | expect( test1.output ).toEqual( ['t e x t'] ); |
99 | 99 | | expect( test1.lines ).toEqual( 1 ); |
100 | 100 | | |
101 | 101 | | const test2 = RenderConsole( 'text', { |
102 | 102 | | align: 'left', |
103 | 103 | | colors: [], |
104 | 104 | | letterSpacing: 3, |
105 | | - | lineHeight: 1, |
| 105 | + | lineHeight: 0, |
106 | 106 | | }, { width: 100, height: 10 } ); |
107 | 107 | | |
108 | | - | expect( test2.output ).toEqual( ['t e x t'] ); |
| 108 | + | expect( test2.output ).toEqual( ['t e x t'] ); |
109 | 109 | | expect( test2.lines ).toEqual( 1 ); |
110 | 110 | | |
111 | 111 | | const test3 = RenderConsole( 'text', { |
112 | 112 | | align: 'left', |
113 | 113 | | colors: [], |
114 | 114 | | letterSpacing: 10, |
115 | | - | lineHeight: 1, |
| 115 | + | lineHeight: 0, |
116 | 116 | | }, { width: 100, height: 10 } ); |
117 | 117 | | |
118 | | - | expect( test3.output ).toEqual( ['t e x t'] ); |
| 118 | + | expect( test3.output ).toEqual( ['t e x t'] ); |
119 | 119 | | expect( test3.lines ).toEqual( 1 ); |
120 | 120 | | }); |
121 | 121 | | |
| skipped 3 lines |
125 | 125 | | align: 'left', |
126 | 126 | | colors: [], |
127 | 127 | | letterSpacing: 2, |
128 | | - | lineHeight: 1, |
| 128 | + | lineHeight: 0, |
129 | 129 | | }, { width: 10, height: 10 } ); |
130 | 130 | | |
131 | | - | expect( test1.output ).toEqual( ['t e x t', 't e x t'] ); |
| 131 | + | expect( test1.output ).toEqual( ['t e x t', 't e x t'] ); |
132 | 132 | | expect( test1.lines ).toEqual( 2 ); |
133 | 133 | | |
134 | 134 | | const test2 = RenderConsole( 'text|text', { |
135 | 135 | | align: 'left', |
136 | 136 | | colors: [], |
137 | 137 | | letterSpacing: 3, |
138 | | - | lineHeight: 1, |
| 138 | + | lineHeight: 0, |
139 | 139 | | }, { width: 100, height: 10 } ); |
140 | 140 | | |
141 | | - | expect( test2.output ).toEqual( ['t e x t', 't e x t'] ); |
| 141 | + | expect( test2.output ).toEqual( ['t e x t', 't e x t'] ); |
142 | 142 | | expect( test2.lines ).toEqual( 2 ); |
143 | 143 | | |
144 | 144 | | const test3 = RenderConsole( 'text|text', { |
145 | 145 | | align: 'left', |
146 | 146 | | colors: [], |
147 | 147 | | letterSpacing: 10, |
148 | | - | lineHeight: 1, |
| 148 | + | lineHeight: 0, |
149 | 149 | | }, { width: 100, height: 10 } ); |
150 | 150 | | |
151 | | - | expect( test3.output ).toEqual( ['t e x t', 't e x t'] ); |
| 151 | + | expect( test3.output ).toEqual( ['t e x t', 't e x t'] ); |
152 | 152 | | expect( test3.lines ).toEqual( 2 ); |
153 | 153 | | }); |
154 | 154 | | |
| skipped 2 lines |
157 | 157 | | const test1 = RenderConsole( 'text', { |
158 | 158 | | align: 'left', |
159 | 159 | | colors: [], |
160 | | - | letterSpacing: 1, |
161 | | - | lineHeight: 2, |
| 160 | + | letterSpacing: 0, |
| 161 | + | lineHeight: 1, |
162 | 162 | | }, { width: 100, height: 10 } ); |
163 | 163 | | |
164 | | - | expect( test1.output ).toEqual( ['text', ''] ); |
165 | | - | expect( test1.lines ).toEqual( 2 ); |
| 164 | + | expect( test1.output ).toEqual( ['text'] ); |
| 165 | + | expect( test1.lines ).toEqual( 1 ); |
166 | 166 | | |
167 | | - | const test2 = RenderConsole( 'text', { |
| 167 | + | const test2 = RenderConsole( 'text|text', { |
168 | 168 | | align: 'left', |
169 | 169 | | colors: [], |
170 | | - | letterSpacing: 1, |
| 170 | + | letterSpacing: 0, |
171 | 171 | | lineHeight: 3, |
172 | 172 | | }, { width: 100, height: 10 } ); |
173 | 173 | | |
174 | | - | expect( test2.output ).toEqual( ['text', '', ''] ); |
175 | | - | expect( test2.lines ).toEqual( 3 ); |
| 174 | + | expect( test2.output ).toEqual( ['text', '', '', '','text'] ); |
| 175 | + | expect( test2.lines ).toEqual( 2 ); |
176 | 176 | | |
177 | | - | const test3 = RenderConsole( 'text', { |
| 177 | + | const test3 = RenderConsole( 'text|text', { |
178 | 178 | | align: 'left', |
179 | 179 | | colors: [], |
180 | | - | letterSpacing: 1, |
| 180 | + | letterSpacing: 0, |
181 | 181 | | lineHeight: 10, |
182 | 182 | | }, { width: 100, height: 10 } ); |
183 | 183 | | |
184 | | - | expect( test3.output ).toEqual( ['text', '', '', '', '', '', '', '', '', ''] ); |
185 | | - | expect( test3.lines ).toEqual( 10 ); |
| 184 | + | expect( test3.output ).toEqual( ['text', '', '', '', '', '', '', '', '', '', '', 'text'] ); |
| 185 | + | expect( test3.lines ).toEqual( 2 ); |
186 | 186 | | }); |
187 | 187 | | |
188 | 188 | | |
| skipped 1 lines |
190 | 190 | | const test1 = RenderConsole( 'text|text|text', { |
191 | 191 | | align: 'left', |
192 | 192 | | colors: [], |
193 | | - | letterSpacing: 1, |
| 193 | + | letterSpacing: 0, |
194 | 194 | | lineHeight: 2, |
195 | 195 | | }, { width: 100, height: 10 } ); |
196 | 196 | | |
197 | | - | expect( test1.output ).toEqual( ['text', '', 'text', '', 'text', ''] ); |
198 | | - | expect( test1.lines ).toEqual( 6 ); |
| 197 | + | expect( test1.output ).toEqual( ['text', '', '', 'text', '', '', 'text'] ); |
| 198 | + | expect( test1.lines ).toEqual( 3 ); |
199 | 199 | | |
200 | 200 | | const test2 = RenderConsole( 'text|text|text', { |
201 | 201 | | align: 'left', |
202 | 202 | | colors: [], |
203 | | - | letterSpacing: 1, |
| 203 | + | letterSpacing: 0, |
204 | 204 | | lineHeight: 3, |
205 | 205 | | }, { width: 100, height: 10 } ); |
206 | 206 | | |
207 | | - | expect( test2.output ).toEqual( ['text', '', '', 'text', '', '', 'text', '', ''] ); |
208 | | - | expect( test2.lines ).toEqual( 9 ); |
| 207 | + | expect( test2.output ).toEqual( ['text', '', '', '', 'text', '', '', '', 'text'] ); |
| 208 | + | expect( test2.lines ).toEqual( 3 ); |
209 | 209 | | |
210 | 210 | | const test3 = RenderConsole( 'text|text|text', { |
211 | 211 | | align: 'left', |
212 | 212 | | colors: [], |
213 | | - | letterSpacing: 1, |
| 213 | + | letterSpacing: 0, |
214 | 214 | | lineHeight: 10, |
215 | 215 | | }, { width: 100, height: 10 } ); |
216 | 216 | | |
217 | 217 | | expect( test3.output ).toEqual([ |
218 | | - | 'text', '', '', '', '', '', '', '', '', '', |
219 | | - | 'text', '', '', '', '', '', '', '', '', '', |
220 | | - | 'text', '', '', '', '', '', '', '', '', '', |
| 218 | + | 'text', |
| 219 | + | '', '', '', '', '', '', '', '', '', '', |
| 220 | + | 'text', |
| 221 | + | '', '', '', '', '', '', '', '', '', '', |
| 222 | + | 'text', |
221 | 223 | | ]); |
222 | | - | expect( test3.lines ).toEqual( 30 ); |
| 224 | + | expect( test3.lines ).toEqual( 3 ); |
223 | 225 | | }); |
224 | 226 | | |
225 | 227 | | |
| skipped 1 lines |
227 | 229 | | const test1 = RenderConsole( 'this is a long line', { |
228 | 230 | | align: 'left', |
229 | 231 | | colors: [], |
230 | | - | letterSpacing: 1, |
| 232 | + | letterSpacing: 0, |
231 | 233 | | lineHeight: 2, |
232 | 234 | | }, { width: 10, height: 10 } ); |
233 | 235 | | |
234 | | - | expect( test1.output ).toEqual( ['this is a', '', 'long line', ''] ); |
235 | | - | expect( test1.lines ).toEqual( 4 ); |
| 236 | + | expect( test1.output ).toEqual( ['this is a ', '', '', 'long line'] ); |
| 237 | + | expect( test1.lines ).toEqual( 2 ); |
236 | 238 | | |
237 | 239 | | const test2 = RenderConsole( 'this is a long line', { |
238 | 240 | | align: 'left', |
239 | 241 | | colors: [], |
240 | | - | letterSpacing: 1, |
| 242 | + | letterSpacing: 0, |
241 | 243 | | lineHeight: 3, |
242 | 244 | | }, { width: 10, height: 10 } ); |
243 | 245 | | |
244 | | - | expect( test2.output ).toEqual( ['this is a', '', '', 'long line', '', ''] ); |
245 | | - | expect( test2.lines ).toEqual( 6 ); |
| 246 | + | expect( test2.output ).toEqual( ['this is a ', '', '', '', 'long line'] ); |
| 247 | + | expect( test2.lines ).toEqual( 2 ); |
246 | 248 | | |
247 | 249 | | const test3 = RenderConsole( 'this is a long line', { |
248 | 250 | | align: 'left', |
249 | 251 | | colors: [], |
250 | | - | letterSpacing: 1, |
| 252 | + | letterSpacing: 0, |
251 | 253 | | lineHeight: 10, |
252 | 254 | | }, { width: 10, height: 10 } ); |
253 | 255 | | |
254 | 256 | | expect( test3.output ).toEqual([ |
255 | | - | 'this is a', '', '', '', '', '', '', '', '', '', |
256 | | - | 'long line', '', '', '', '', '', '', '', '', '', |
| 257 | + | 'this is a ', |
| 258 | + | '', '', '', '', '', '', '', '', '', '', |
| 259 | + | 'long line', |
257 | 260 | | ]); |
258 | | - | expect( test3.lines ).toEqual( 20 ); |
| 261 | + | expect( test3.lines ).toEqual( 2 ); |
259 | 262 | | }); |
260 | 263 | | |
261 | 264 | | |
| skipped 1 lines |
263 | 266 | | const test = RenderConsole( 'test', { |
264 | 267 | | align: 'left', |
265 | 268 | | colors: ['red'], |
266 | | - | letterSpacing: 1, |
267 | | - | lineHeight: 1, |
| 269 | + | letterSpacing: 0, |
| 270 | + | lineHeight: 0, |
268 | 271 | | }, { width: 100, height: 10 } ); |
269 | 272 | | |
270 | 273 | | expect( test.output ).toEqual( ['\u001b[38;2;255;0;0mtest\u001b[39m'] ); |
| skipped 5 lines |
276 | 279 | | const test = RenderConsole( 'test', { |
277 | 280 | | align: 'left', |
278 | 281 | | colors: ['candy'], |
279 | | - | letterSpacing: 1, |
280 | | - | lineHeight: 1, |
| 282 | + | letterSpacing: 0, |
| 283 | + | lineHeight: 0, |
281 | 284 | | }, { width: 100, height: 10 } ); |
282 | 285 | | |
283 | 286 | | expect( StripColor( test.output[ 0 ] ) ).toEqual( 'test' ); |
| skipped 1 lines |
285 | 288 | | expect( test.lines ).toEqual( 1 ); |
286 | 289 | | }); |
287 | 290 | | |
| 291 | + | |
| 292 | + | test(`RenderConsole - Should respect small window size`, () => { |
| 293 | + | const test = RenderConsole( 'testing long test', { |
| 294 | + | align: 'left', |
| 295 | + | colors: [], |
| 296 | + | letterSpacing: 0, |
| 297 | + | lineHeight: 0, |
| 298 | + | maxLength: 8, |
| 299 | + | }, { width: 7, height: 10 } ); |
| 300 | + | |
| 301 | + | expect( test.output ).toEqual([ 'testing', ' long t', 'est' ]); |
| 302 | + | expect( test.lines ).toEqual( 3 ); |
| 303 | + | }); |
| 304 | + | |
| 305 | + | |
| 306 | + | test(`RenderConsole - Should respect small maxLength over window size`, () => { |
| 307 | + | const test = RenderConsole( 'testing long test', { |
| 308 | + | align: 'left', |
| 309 | + | colors: [], |
| 310 | + | letterSpacing: 0, |
| 311 | + | lineHeight: 0, |
| 312 | + | maxLength: 5, |
| 313 | + | }, { width: 7, height: 10 } ); |
| 314 | + | |
| 315 | + | expect( test.output ).toEqual([ 'testi', 'ng lo', 'ng te', 'st' ]); |
| 316 | + | expect( test.lines ).toEqual( 4 ); |
| 317 | + | }); |
| 318 | + | |