break.js 853 B

123456789101112131415161718192021222324252627282930
  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. };