JAVASCRIPT 26
Break.js Guest on 1st May 2021 03:48:53 PM
  1. var assert = require('assert');
  2. var wordwrap = require('../');
  3.  
  4. exports.hard = function () {
  5.     var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,'
  6.         + '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",'
  7.         + '"browser":"chrome/6.0"}'
  8.     ;
  9.     var s_ = wordwrap.hard(80)(s);
  10.    
  11.     var lines = s_.split('\n');
  12.     assert.equal(lines.length, 2);
  13.     assert.ok(lines[0].length < 80);
  14.     assert.ok(lines[1].length < 80);
  15.    
  16.     assert.equal(s, s_.replace(/\n/g, ''));
  17. };
  18.  
  19. exports.break = function () {
  20.     var s = new Array(55+1).join('a');
  21.     var s_ = wordwrap.hard(20)(s);
  22.    
  23.     var lines = s_.split('\n');
  24.     assert.equal(lines.length, 3);
  25.     assert.ok(lines[0].length === 20);
  26.     assert.ok(lines[1].length === 20);
  27.     assert.ok(lines[2].length === 15);
  28.    
  29.     assert.equal(s, s_.replace(/\n/g, ''));
  30. };

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.