Skip to content

Commit

Permalink
Remove default indent
Browse files Browse the repository at this point in the history
  • Loading branch information
mohd-akram committed Jun 14, 2017
1 parent 41827b1 commit 0a0e06b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .verb.md
Expand Up @@ -41,7 +41,7 @@ wrap(str, {width: 60});

Type: `String`

Default: ` ` (two spaces)
Default: `` (none)

The string to use at the beginning of each line.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -50,7 +50,7 @@ wrap(str, {width: 60});

Type: `String`

Default: `` (two spaces)
Default: `` (none)

The string to use at the beginning of each line.

Expand Down Expand Up @@ -179,4 +179,4 @@ Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 02, 2017._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 02, 2017._
4 changes: 2 additions & 2 deletions index.d.ts
Expand Up @@ -16,7 +16,7 @@ declare namespace wrap {

/**
* The string to use at the beginning of each line.
* @default ´ ´ (two spaces)
* @default ´´ (none)
*/
indent?: string;

Expand Down Expand Up @@ -47,4 +47,4 @@ declare namespace wrap {
*/
cut?: boolean;
}
}
}
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -14,7 +14,7 @@ module.exports = function(str, options) {
var width = options.width || 50;
var indent = (typeof options.indent === 'string')
? options.indent
: ' ';
: '';

var newline = options.newline || '\n' + indent;
var escape = typeof options.escape === 'function'
Expand Down
24 changes: 12 additions & 12 deletions test.js
Expand Up @@ -8,58 +8,58 @@ var str = 'A project without documentation is like a project that doesn\'t exist

describe('wrap', function () {
it('should use defaults to wrap words in the given string:', function () {
assert.equal(wrap(str), ' A project without documentation is like a project \n that doesn\'t exist. Verb solves this by making it \n dead simple to generate project documentation, \n using simple markdown templates, with zero \n configuration required. ');
assert.equal(wrap(str), 'A project without documentation is like a project \nthat doesn\'t exist. Verb solves this by making it \ndead simple to generate project documentation, \nusing simple markdown templates, with zero \nconfiguration required. ');
});

it('should wrap to the specified width:', function () {
assert.equal(wrap(str, {width: 40}), ' A project without documentation is like \n a project that doesn\'t exist. Verb \n solves this by making it dead simple to \n generate project documentation, using \n simple markdown templates, with zero \n configuration required. ');
assert.equal(wrap(str, {width: 40}), 'A project without documentation is like \na project that doesn\'t exist. Verb \nsolves this by making it dead simple to \ngenerate project documentation, using \nsimple markdown templates, with zero \nconfiguration required. ');
});

it('should indent the specified amount:', function () {
assert.equal(wrap(str, {indent: ' '}), ' A project without documentation is like a project \n that doesn\'t exist. Verb solves this by making it \n dead simple to generate project documentation, \n using simple markdown templates, with zero \n configuration required. ');
});

it('should use the given string for newlines:', function () {
assert.equal(wrap(str, {newline: '\n\n-'}), ' A project without documentation is like a project \n\n-that doesn\'t exist. Verb solves this by making it \n\n-dead simple to generate project documentation, \n\n-using simple markdown templates, with zero \n\n-configuration required. ');
assert.equal(wrap(str, {newline: '\n\n-'}), 'A project without documentation is like a project \n\n-that doesn\'t exist. Verb solves this by making it \n\n-dead simple to generate project documentation, \n\n-using simple markdown templates, with zero \n\n-configuration required. ');
});

it('should run the escape function on each line', function () {
assert.equal(
wrap(str, {escape: function(e) {return e.replace('\'', '\\\'')}}),
' A project without documentation is like a project \n that doesn\\\'t exist. Verb solves this by making it \n dead simple to generate project documentation, \n using simple markdown templates, with zero \n configuration required. '
'A project without documentation is like a project \nthat doesn\\\'t exist. Verb solves this by making it \ndead simple to generate project documentation, \nusing simple markdown templates, with zero \nconfiguration required. '
)
});

it('should trim trailing whitespace:', function () {
assert.equal(wrap(str, {trim: true}), ' A project without documentation is like a project\n that doesn\'t exist. Verb solves this by making it\n dead simple to generate project documentation,\n using simple markdown templates, with zero\n configuration required.');
assert.equal(wrap(str, {trim: true}), 'A project without documentation is like a project\nthat doesn\'t exist. Verb solves this by making it\ndead simple to generate project documentation,\nusing simple markdown templates, with zero\nconfiguration required.');
});

it('should handle strings with just newlines', function () {
assert.equal(wrap('\r\n', {indent: '\r\n', width: 18}), '\r\n');
});

it('should handle newlines that occur at the same position as `options.width`', function () {
assert.equal(wrap('asdfg\nqwert', {width:5}), ' asdfg\n qwert');
assert.equal(wrap('aaaaaa\nbbbbbb\ncccccc', {width:6}), ' aaaaaa\n bbbbbb\n cccccc');
assert.equal(wrap('asdfg\nqwert', {width:5}), 'asdfg\nqwert');
assert.equal(wrap('aaaaaa\nbbbbbb\ncccccc', {width:6}), 'aaaaaa\nbbbbbb\ncccccc');
});

it('should handle strings that break where there are multiple spaces', function() {
assert.equal(wrap('foo foo. bar', {width:8}), ' foo foo. \n bar');
assert.equal(wrap('foo foo. bar', {width:8, trim: true}), ' foo foo.\n bar');
assert.equal(wrap('foo foo. bar', {width:8}), 'foo foo. \nbar');
assert.equal(wrap('foo foo. bar', {width:8, trim: true}), 'foo foo.\nbar');
});

it('should cut one long word', function() {
assert.equal(wrap('Supercalifragilisticexpialidocious', {width:24, cut:true}), ' Supercalifragilisticexpi\n alidocious');
assert.equal(wrap('Supercalifragilisticexpialidocious', {width:24, cut:true}), 'Supercalifragilisticexpi\nalidocious');
});

it('should cut long words', function() {
assert.equal(wrap('Supercalifragilisticexpialidocious and Supercalifragilisticexpialidocious', {width:24, cut:true}), ' Supercalifragilisticexpi\n alidocious and Supercali\n fragilisticexpialidociou\n s');
assert.equal(wrap('Supercalifragilisticexpialidocious and Supercalifragilisticexpialidocious', {width:24, cut:true}), 'Supercalifragilisticexpi\nalidocious and Supercali\nfragilisticexpialidociou\ns');
});

it('should wrap on zero space characters', function () {
assert.equal(
wrap('Supercalifragilistic\u200Bexpialidocious', {width: 24}),
' Supercalifragilistic\u200B\n expialidocious'
'Supercalifragilistic\u200B\nexpialidocious'
);
});
});

0 comments on commit 0a0e06b

Please sign in to comment.