Debian Codegraph @

test/other/test-help-formatter.js

raw
1 var formatOption = require('../../lib/util/help-formatter').formatOption,
2 THRESHOLD = 20;
3
4 module.exports = {
5 "should format small option + text on a single line": function (test) {
6 var formatted = formatOption('-f', 'specify force override of defaults');
7 console.log(formatted);
8 test.ok(formatted.indexOf('\n') < 0);
9 test.done();
10 },
11 "should format small option + big text on multiple lines": function (test) {
12 var formatted = formatOption('-f', 'an option whose description should exceed the length of a line if we have done our job well');
13 console.log(formatted);
14 test.ok(formatted.indexOf('\n') > THRESHOLD);
15 test.done();
16 },
17 "should format long option + small text on multiple lines": function (test) {
18 var formatted = formatOption('--[no]force', 'specify force override of defaults');
19 console.log(formatted);
20 test.ok(formatted.indexOf('\n') < THRESHOLD);
21 test.ok(formatted.lastIndexOf('\n') < THRESHOLD);
22 test.done();
23 },
24 "should format long option + big text on 3 lines": function (test) {
25 var formatted = formatOption('--[no]force', 'an option whose description should exceed the length of a line if we have done our job well');
26 console.log(formatted);
27 test.ok(formatted.indexOf('\n') < THRESHOLD);
28 test.ok(formatted.lastIndexOf('\n') > THRESHOLD);
29 test.done();
30 }
31 };