l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

break.js (853B)


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