Aucune description

humanize.spec.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. var should = require('should');
  2. var humanize = require('../humanize');
  3. process.env.TZ = 'America/Los_Angeles';
  4. describe('humanize:', function() {
  5. describe('#pad', function() {
  6. it('should be able to pad on the left', function() {
  7. humanize.pad(123, 4, '0').should.equal('0123');
  8. humanize.pad('abcd', 3, 'c').should.equal('abcd');
  9. humanize.pad('cool', 7, 'Blah').should.equal('BBBcool');
  10. });
  11. it('should be able to pad on the right', function() {
  12. humanize.pad(123, 4, '0', 'right').should.equal('1230');
  13. humanize.pad('abcd', 3, 'c', 'right').should.equal('abcd');
  14. humanize.pad('cool', 7, 'Blah', 'right').should.equal('coolBBB');
  15. });
  16. });
  17. describe('#time', function() {
  18. it('should be able to get the current time', function() {
  19. // I'm not sure how to make this better yet ...
  20. parseInt(humanize.time()).should.equal(parseInt(new Date().getTime() / 1000, 10));
  21. });
  22. });
  23. describe('#date', function() {
  24. var timestamps = require('./dateData.js')().timestamps;
  25. it('should be able to accept timestamp, js date object, or nothing', function() {
  26. var timestamp = 514088627;
  27. var today = new Date();
  28. humanize.date('Y-m-d').should.equal(today.getFullYear() + '-' + humanize.pad(today.getMonth() + 1, 2, '0') + '-' + humanize.pad(today.getDate(), 2, '0'));
  29. humanize.date('Y-m-d', timestamp).should.equal('1986-04-16');
  30. humanize.date('Y-m-d', new Date(timestamp * 1000)).should.equal('1986-04-16');
  31. });
  32. it('should be able to print out escaped characters', function() {
  33. var timestamp = 514088627;
  34. var today = new Date();
  35. humanize.date('Y-m-d\\Y\\z\\d').should.equal(today.getFullYear() + '-' + humanize.pad(today.getMonth() + 1, 2, '0') + '-' + humanize.pad(today.getDate(), 2, '0') + 'Yzd');
  36. humanize.date('Y-m-d\\Y\\z\\d', timestamp).should.equal('1986-04-16Yzd');
  37. humanize.date('Y-m-d\\Y\\z\\d', new Date(timestamp * 1000)).should.equal('1986-04-16Yzd');
  38. });
  39. it('should be able to replace correct information', function() {
  40. for (var timestamp in timestamps) {
  41. for (var dateVal in timestamps[timestamp]) {
  42. var info = 'timestamp: ' + timestamp + ' dateVal: ' + dateVal;
  43. humanize.date(dateVal, timestamp).should.eql(timestamps[timestamp][dateVal], info);
  44. }
  45. }
  46. });
  47. });
  48. describe('#numberFormat', function() {
  49. var number = 1234567.1234567;
  50. var negNumber = -1234567.1234567;
  51. it('should default using 2 decimals, "." as decimal point, "," as thousands separator', function() {
  52. humanize.numberFormat(number).should.equal('1,234,567.12');
  53. });
  54. it('should be able to deal with different number of decimals properly + rounding', function() {
  55. humanize.numberFormat(number, 0).should.equal('1,234,567');
  56. humanize.numberFormat(number, 3).should.equal('1,234,567.123');
  57. humanize.numberFormat(number, 4).should.equal('1,234,567.1235');
  58. humanize.numberFormat(number, 5).should.equal('1,234,567.12346');
  59. humanize.numberFormat(number, 6).should.equal('1,234,567.123457');
  60. humanize.numberFormat(number, 7).should.equal('1,234,567.1234567');
  61. humanize.numberFormat(number, 8).should.equal('1,234,567.12345670');
  62. humanize.numberFormat(number, 9).should.equal('1,234,567.123456700');
  63. humanize.numberFormat(negNumber, 0).should.equal('-1,234,567');
  64. humanize.numberFormat(negNumber, 3).should.equal('-1,234,567.123');
  65. humanize.numberFormat(negNumber, 4).should.equal('-1,234,567.1235');
  66. humanize.numberFormat(negNumber, 5).should.equal('-1,234,567.12346');
  67. humanize.numberFormat(negNumber, 6).should.equal('-1,234,567.123457');
  68. humanize.numberFormat(negNumber, 7).should.equal('-1,234,567.1234567');
  69. humanize.numberFormat(negNumber, 8).should.equal('-1,234,567.12345670');
  70. humanize.numberFormat(negNumber, 9).should.equal('-1,234,567.123456700');
  71. });
  72. it('should be able to deal with negative decimals as if they were positive', function() {
  73. humanize.numberFormat(number, -3).should.equal(humanize.numberFormat(number, 3));
  74. });
  75. it('should be able to change the decimal point to a different string', function() {
  76. humanize.numberFormat(number, 3, 'P').should.equal('1,234,567P123');
  77. humanize.numberFormat(number, 3, ',').should.equal('1,234,567,123');
  78. humanize.numberFormat(number, 3, 'what?').should.equal('1,234,567what?123');
  79. });
  80. it('should be able to change the thousands separator to a different string', function() {
  81. humanize.numberFormat(number, 3, '.', '.').should.equal('1.234.567.123');
  82. humanize.numberFormat(number, 3, ',', '.').should.equal('1.234.567,123');
  83. humanize.numberFormat(number, 3, '.', 'huh?').should.equal('1huh?234huh?567.123');
  84. });
  85. });
  86. describe('#naturalDay', function() {
  87. var d = new Date();
  88. var today = (new Date(d.getFullYear(), d.getMonth(), d.getDate())).getTime() / 1000;
  89. it('should return today when using today', function() {
  90. humanize.naturalDay(today).should.equal('today');
  91. humanize.naturalDay(today + 43200).should.equal('today');
  92. humanize.naturalDay(today + 86399).should.equal('today');
  93. });
  94. it('should return yesterday when using yesterday', function() {
  95. humanize.naturalDay(today - 1).should.equal('yesterday');
  96. humanize.naturalDay(today - 43200).should.equal('yesterday');
  97. humanize.naturalDay(today - 86400).should.equal('yesterday');
  98. });
  99. it('should return tomorrow when using tomorrow', function() {
  100. humanize.naturalDay(today + 86400).should.equal('tomorrow');
  101. humanize.naturalDay(today + 86400 + 43200).should.equal('tomorrow');
  102. humanize.naturalDay(today + 86400 + 86399).should.equal('tomorrow');
  103. });
  104. it('should return date when before yesterday with default formatting', function() {
  105. humanize.naturalDay(today - 86401).should.equal(humanize.date('Y-m-d', today - 86401));
  106. humanize.naturalDay(today - 86411).should.equal(humanize.date('Y-m-d', today - 86411));
  107. humanize.naturalDay(today - (2 * 86401)).should.equal(humanize.date('Y-m-d', today - (2 * 86401)));
  108. });
  109. it('should return date when before yesterday with custom formatting', function() {
  110. humanize.naturalDay(today - 86401, 'h:i:s').should.equal(humanize.date('h:i:s', today - 86401));
  111. humanize.naturalDay(today - 86401, 'l F j, Y h:i:s').should.equal(humanize.date('l F j, Y h:i:s', today - 86401));
  112. });
  113. it('should return date when after tomorrow', function() {
  114. humanize.naturalDay(today + 86400 + 86401).should.equal(humanize.date('Y-m-d', today + 86400 + 86401));
  115. humanize.naturalDay(today + 86400 + 86411).should.equal(humanize.date('Y-m-d', today + 86400 + 86411));
  116. humanize.naturalDay(today + (2 * 86401)).should.equal(humanize.date('Y-m-d', today + (2 * 86401)));
  117. });
  118. it('should return date when before tomorrow with custom formatting', function() {
  119. humanize.naturalDay(today + 86400 + 86401, 'h:i:s').should.equal(humanize.date('h:i:s', today + 86400 + 86401));
  120. humanize.naturalDay(today + 86400 + 86401, 'l F j, Y h:i:s').should.equal(humanize.date('l F j, Y h:i:s', today + 86400 + 86401));
  121. });
  122. });
  123. describe('#relativeTime', function() {
  124. it('should return just now for anything within 2 seconds', function() {
  125. humanize.relativeTime(humanize.time() - 1).should.equal('just now');
  126. humanize.relativeTime(humanize.time() - .5).should.equal('just now');
  127. humanize.relativeTime(humanize.time()).should.equal('just now');
  128. humanize.relativeTime(humanize.time() + .5).should.equal('now');
  129. humanize.relativeTime(humanize.time() + 1).should.equal('now');
  130. });
  131. it('should return (in) X seconds (ago) for anything between 2 seconds and 59 seconds inclusive', function() {
  132. humanize.relativeTime(humanize.time() - 59).should.equal('59 seconds ago');
  133. humanize.relativeTime(humanize.time() - 37).should.equal('37 seconds ago');
  134. humanize.relativeTime(humanize.time() - 37.3).should.equal('37 seconds ago');
  135. humanize.relativeTime(humanize.time() - 2).should.equal('2 seconds ago');
  136. humanize.relativeTime(humanize.time() + 2).should.equal('in 2 seconds');
  137. humanize.relativeTime(humanize.time() + 22).should.equal('in 22 seconds');
  138. humanize.relativeTime(humanize.time() + 22.7).should.equal('in 22 seconds');
  139. humanize.relativeTime(humanize.time() + 59).should.equal('in 59 seconds');
  140. });
  141. it('should return (in) about a minute (ago) for anything between 1 minute (inclusive) and 2 minutes (exclusive)', function() {
  142. humanize.relativeTime(humanize.time() - 119).should.equal('about a minute ago');
  143. humanize.relativeTime(humanize.time() - 73).should.equal('about a minute ago');
  144. humanize.relativeTime(humanize.time() - 60).should.equal('about a minute ago');
  145. humanize.relativeTime(humanize.time() + 60).should.equal('in about a minute');
  146. humanize.relativeTime(humanize.time() + 90).should.equal('in about a minute');
  147. humanize.relativeTime(humanize.time() + 119).should.equal('in about a minute');
  148. });
  149. it('should return (in) X minutes (ago) for anything between 2 minutes (inclusive) and 60 minutes (exclusive)', function() {
  150. humanize.relativeTime(humanize.time() - 59*60 - 59).should.equal('59 minutes ago');
  151. humanize.relativeTime(humanize.time() - 59*60 - 10).should.equal('59 minutes ago');
  152. humanize.relativeTime(humanize.time() - 33*60 - 17).should.equal('33 minutes ago');
  153. humanize.relativeTime(humanize.time() - 33*60 - 35).should.equal('33 minutes ago');
  154. humanize.relativeTime(humanize.time() - 120).should.equal('2 minutes ago');
  155. humanize.relativeTime(humanize.time() + 120).should.equal('in 2 minutes');
  156. humanize.relativeTime(humanize.time() + 24*60 + 17).should.equal('in 24 minutes');
  157. humanize.relativeTime(humanize.time() + 47*60 + 35).should.equal('in 47 minutes');
  158. humanize.relativeTime(humanize.time() + 59*60 + 16).should.equal('in 59 minutes');
  159. humanize.relativeTime(humanize.time() + 59*60 + 59).should.equal('in 59 minutes');
  160. });
  161. it('should return (in) about an hour (ago) for anything between 1 hour (inclusive) and 2 hours (exclusive)', function() {
  162. humanize.relativeTime(humanize.time() - 7199).should.equal('about an hour ago');
  163. humanize.relativeTime(humanize.time() - 3601).should.equal('about an hour ago');
  164. humanize.relativeTime(humanize.time() - 3600).should.equal('about an hour ago');
  165. humanize.relativeTime(humanize.time() + 3600).should.equal('in about an hour');
  166. humanize.relativeTime(humanize.time() + 5974).should.equal('in about an hour');
  167. humanize.relativeTime(humanize.time() + 7199).should.equal('in about an hour');
  168. });
  169. it('should return (in) X hours (ago) for anything between 2 hours (inclusive) and 24 hours (exclusive)', function() {
  170. humanize.relativeTime(humanize.time() - 86399).should.equal('23 hours ago');
  171. humanize.relativeTime(humanize.time() - (3*3600 + 56)).should.equal('3 hours ago');
  172. humanize.relativeTime(humanize.time() - (15*3600 + 3599)).should.equal('15 hours ago');
  173. humanize.relativeTime(humanize.time() - 7200).should.equal('2 hours ago');
  174. humanize.relativeTime(humanize.time() + 7200).should.equal('in 2 hours');
  175. humanize.relativeTime(humanize.time() + (10*3600 + 997)).should.equal('in 10 hours');
  176. humanize.relativeTime(humanize.time() + (15*3600 + 3599)).should.equal('in 15 hours');
  177. humanize.relativeTime(humanize.time() + 86399).should.equal('in 23 hours');
  178. });
  179. it('should return (in) X day(s) (ago) for anything between 1 day (inclusive) and 29 days (exclusive)', function() {
  180. humanize.relativeTime(humanize.time() - (29*86400 - 1)).should.equal('28 days ago');
  181. humanize.relativeTime(humanize.time() - (2*86400)).should.equal('2 days ago');
  182. humanize.relativeTime(humanize.time() - (2*86400 - 1)).should.equal('1 day ago');
  183. humanize.relativeTime(humanize.time() - 86400).should.equal('1 day ago');
  184. humanize.relativeTime(humanize.time() + 86400).should.equal('in 1 day');
  185. humanize.relativeTime(humanize.time() + (2*86400)).should.equal('in 2 days');
  186. humanize.relativeTime(humanize.time() + (29*86400 - 1)).should.equal('in 28 days');
  187. });
  188. it('should return (in) about a month (ago) for anything between 28 days (inclusive) to 60 days (exclusive)', function() {
  189. humanize.relativeTime(humanize.time() - (60*86400 - 1)).should.equal('about a month ago');
  190. humanize.relativeTime(humanize.time() - (29*86400)).should.equal('about a month ago');
  191. humanize.relativeTime(humanize.time() + (29*86400)).should.equal('in about a month');
  192. humanize.relativeTime(humanize.time() + (60*86400 - 1)).should.equal('in about a month');
  193. });
  194. it('should return (in) X months (ago) using month arithmetic', function() {
  195. humanize.relativeTime(humanize.time() - (60*86400)).should.equal('2 months ago');
  196. humanize.relativeTime(humanize.time() + (60*86400)).should.equal('in 2 months');
  197. var d = new Date();
  198. var monthsAgo4 = (new Date(d.getFullYear(), d.getMonth() - 4, d.getDate())).getTime() / 1000;
  199. humanize.relativeTime(monthsAgo4).should.equal('4 months ago');
  200. var monthsFuture4 = (new Date(d.getFullYear(), d.getMonth() + 4, d.getDate())).getTime() / 1000;
  201. humanize.relativeTime(monthsFuture4).should.equal('in 4 months');
  202. var monthsAgo11 = (new Date(d.getFullYear(), d.getMonth() - 11, d.getDate())).getTime() / 1000;
  203. humanize.relativeTime(monthsAgo11).should.equal('11 months ago');
  204. var monthsFuture11 = (new Date(d.getFullYear(), d.getMonth() + 11, d.getDate())).getTime() / 1000;
  205. humanize.relativeTime(monthsFuture11).should.equal('in 11 months');
  206. });
  207. it('should return (in) X year(s) (ago) for anything over a year via year arithmetic', function() {
  208. var d = new Date();
  209. var yearsAgo1 = (new Date(d.getFullYear() - 1, d.getMonth(), d.getDate())).getTime() / 1000;
  210. humanize.relativeTime(yearsAgo1).should.equal('a year ago');
  211. var yearsFuture1 = (new Date(d.getFullYear() + 1, d.getMonth(), d.getDate())).getTime() / 1000;
  212. humanize.relativeTime(yearsFuture1).should.equal('in a year');
  213. var june1 = (new Date(d.getFullYear(), 5, 1));
  214. var yearsAgo2 = (new Date(june1.getFullYear() - 2, june1.getMonth() + 6, june1.getDate() + 19)).getTime() / 1000;
  215. humanize.relativeTime(yearsAgo2).should.equal('2 years ago');
  216. var wrapToYearsAgo1 = (new Date(june1.getFullYear() - 2, june1.getMonth() + 7, june1.getDate() + 19)).getTime() / 1000;
  217. humanize.relativeTime(wrapToYearsAgo1).should.equal('a year ago');
  218. var yearsFuture2 = (new Date(june1.getFullYear() + 2, june1.getMonth() + 6, june1.getDate() + 19)).getTime() / 1000;
  219. humanize.relativeTime(yearsFuture2).should.equal('in 2 years');
  220. var wrapToYearsFuture1 = (new Date(june1.getFullYear() + 2, june1.getMonth() - 7, june1.getDate() + 19)).getTime() / 1000;
  221. humanize.relativeTime(wrapToYearsFuture1).should.equal('in a year');
  222. });
  223. });
  224. describe('#ordinal', function() {
  225. it('should be able to return the correct ordinal string', function() {
  226. var tests = {
  227. 0: '0th',
  228. 1: '1st',
  229. 2: '2nd',
  230. 3: '3rd',
  231. 4: '4th',
  232. 5: '5th',
  233. 11: '11th',
  234. 12: '12th',
  235. 13: '13th',
  236. 21: '21st',
  237. 31: '31st',
  238. 32: '32nd',
  239. 43: '43rd',
  240. '87 Street': '87th',
  241. '223 APT 23': '223rd',
  242. 'APT': '0th',
  243. '-1': '-1st',
  244. '-2': '-2nd',
  245. '-3': '-3rd',
  246. 112: '112th'
  247. };
  248. for (var num in tests) {
  249. humanize.ordinal(num).should.equal(tests[num]);
  250. }
  251. });
  252. });
  253. describe('#filesize', function() {
  254. it('should be able to use the defaults properly', function() {
  255. humanize.filesize(12).should.equal('12 bytes');
  256. humanize.filesize(1021).should.equal('1,021 bytes');
  257. humanize.filesize(1024).should.equal('1.00 KB');
  258. humanize.filesize(Math.pow(1024, 2)).should.equal('1.00 MB');
  259. humanize.filesize(Math.pow(1024, 3)).should.equal('1.00 GB');
  260. humanize.filesize(Math.pow(1024, 4)).should.equal('1.00 TB');
  261. humanize.filesize(Math.pow(1024, 5)).should.equal('1.00 PB');
  262. humanize.filesize(Math.pow(1024, 6)).should.equal('1,024.00 PB');
  263. humanize.filesize(1234567890).should.equal('1.15 GB');
  264. });
  265. it('should be able to change kilo to a different value', function() {
  266. humanize.filesize(12, 1000).should.equal('12 bytes');
  267. humanize.filesize(1021, 1000).should.equal('1.02 KB');
  268. humanize.filesize(1024, 1000).should.equal('1.02 KB');
  269. humanize.filesize(Math.pow(1024, 2), 1000).should.equal('1.05 MB');
  270. humanize.filesize(Math.pow(1024, 3), 1000).should.equal('1.07 GB');
  271. humanize.filesize(Math.pow(1024, 4), 1000).should.equal('1.10 TB');
  272. humanize.filesize(Math.pow(1024, 5), 1000).should.equal('1.13 PB');
  273. humanize.filesize(Math.pow(1024, 6), 1000).should.equal('1,152.92 PB');
  274. humanize.filesize(1234567890, 1000).should.equal('1.23 GB');
  275. });
  276. });
  277. describe('#intword', function() {
  278. it('should be able to use the defaults properly', function() {
  279. humanize.intword(12).should.equal('12.00');
  280. humanize.intword(999).should.equal('999.00');
  281. humanize.intword(1001).should.equal('1.00K');
  282. humanize.intword(Math.pow(1000, 2)).should.equal('1.00M');
  283. humanize.intword(Math.pow(1000, 3)).should.equal('1.00B');
  284. humanize.intword(Math.pow(1000, 4)).should.equal('1.00T');
  285. humanize.intword(1234567890).should.equal('1.23B');
  286. });
  287. it('should be able to change units or kilo to a different value', function() {
  288. var units = ['ones', 'thousands', 'millions', 'billions', 'trillions'];
  289. humanize.intword(12, units, 1000, 0, '.', ',', ' ').should.equal('12 ones');
  290. humanize.intword(999, units, 1000, 0, '.', ',', ' ').should.equal('999 ones');
  291. humanize.intword(1024, units, 1000, 0, '.', ',', ' ').should.equal('1 thousands');
  292. humanize.intword(Math.pow(1000, 2), units, 1000, 0, '.', ',', ' ').should.equal('1 millions');
  293. humanize.intword(Math.pow(1000, 3), units, 1000, 0, '.', ',', ' ').should.equal('1 billions');
  294. humanize.intword(Math.pow(1000, 4), units, 1000, 0, '.', ',', ' ').should.equal('1 trillions');
  295. humanize.intword(1234567890, units, 1000, 0, '.', ',', ' ').should.equal('1 billions');
  296. });
  297. });
  298. describe('#linebreaks', function() {
  299. it('should wrap the string with <p> tags', function() {
  300. humanize.linebreaks('').should.equal('<p></p>');
  301. });
  302. it('should remove new lines at beginning and end', function() {
  303. humanize.linebreaks("Foo\n\nBar\n\n\n").should.equal('<p>Foo</p><p>Bar</p>');
  304. humanize.linebreaks("\n\r\n\rFoo\n\nBar").should.equal('<p>Foo</p><p>Bar</p>');
  305. });
  306. it('should change all new lines into <br> tags', function() {
  307. humanize.linebreaks("Foo\nBar").should.equal('<p>Foo<br />Bar</p>');
  308. humanize.linebreaks("Foo\nBar\r\nBlah").should.equal('<p>Foo<br />Bar<br />Blah</p>');
  309. });
  310. it('should change all multi-new lines into <p> tags', function() {
  311. humanize.linebreaks("Foo\n\nBar").should.equal('<p>Foo</p><p>Bar</p>');
  312. humanize.linebreaks("Foo\n\n\nBar").should.equal('<p>Foo</p><p>Bar</p>');
  313. humanize.linebreaks("Foo\n\n\r\nBar").should.equal('<p>Foo</p><p>Bar</p>');
  314. humanize.linebreaks("Foo\n\n\r\n\rBar").should.equal('<p>Foo</p><p>Bar</p>');
  315. });
  316. });
  317. describe('#nl2br', function() {
  318. it('should change any type of new line into a <br />', function() {
  319. humanize.nl2br('').should.equal('');
  320. humanize.nl2br("\n").should.equal('<br />');
  321. humanize.nl2br("\r").should.equal('<br />');
  322. humanize.nl2br("\r\n").should.equal('<br />');
  323. humanize.nl2br("Foo\nBar").should.equal('Foo<br />Bar');
  324. humanize.nl2br("\r\nFoo\nBar\n").should.equal('<br />Foo<br />Bar<br />');
  325. humanize.nl2br("\r\r\n\nFoo\nBar\n\n\r\n\r").should.equal('<br /><br /><br />Foo<br />Bar<br /><br /><br /><br />');
  326. });
  327. });
  328. describe('#truncatechars', function() {
  329. it('should be able to truncate characters properly', function() {
  330. humanize.truncatechars('foobar', 0).should.equal('…');
  331. humanize.truncatechars('foobar', 1).should.equal('f…');
  332. humanize.truncatechars('foobar', 2).should.equal('fo…');
  333. humanize.truncatechars('foobar', 3).should.equal('foo…');
  334. humanize.truncatechars('foobar', 4).should.equal('foob…');
  335. });
  336. });
  337. describe('#truncatewords', function() {
  338. it('should be able to truncate words properly', function() {
  339. humanize.truncatewords('a b c d e', 0).should.equal('…');
  340. humanize.truncatewords('a b c d e', 1).should.equal('a…');
  341. humanize.truncatewords('a b c d e', 2).should.equal('a b…');
  342. humanize.truncatewords('a b c d e', 3).should.equal('a b c…');
  343. humanize.truncatewords('a b c d e', 4).should.equal('a b c d…');
  344. });
  345. });
  346. });