You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
853 B

7 years ago
  1. var assert = require('assert');
  2. var wordwrap = require('../');
  3. exports.hard = function () {
  4. var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,'
  5. + '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",'
  6. + '"browser":"chrome/6.0"}'
  7. ;
  8. var s_ = wordwrap.hard(80)(s);
  9. var lines = s_.split('\n');
  10. assert.equal(lines.length, 2);
  11. assert.ok(lines[0].length < 80);
  12. assert.ok(lines[1].length < 80);
  13. assert.equal(s, s_.replace(/\n/g, ''));
  14. };
  15. exports.break = function () {
  16. var s = new Array(55+1).join('a');
  17. var s_ = wordwrap.hard(20)(s);
  18. var lines = s_.split('\n');
  19. assert.equal(lines.length, 3);
  20. assert.ok(lines[0].length === 20);
  21. assert.ok(lines[1].length === 20);
  22. assert.ok(lines[2].length === 15);
  23. assert.equal(s, s_.replace(/\n/g, ''));
  24. };