Skip to content

Commit

Permalink
Add failing test case for newlines
Browse files Browse the repository at this point in the history
There are two modes of failure here. The first added test string shows
that indentation is not properly added after a newline. The second
part, which is a new type of test, shows that the line following the
newline does not extend to the full length limit before it is broken
again by this module. (It also shows the first issue, but not part of
the existing test framework, so I thought maybe both are valuable.) To
illustrate:

Expected (there's a newline just before the capital B):

    A a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
        a a a a a a a a a a a
        B b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
        b b b b b b b b b b b

Actual:

    A a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
        a a a a a a a a a a a
    B b b b b b b b b b b b b b b b b b b b b b b b b b b
        b b b b b b b b b b b b b b b b b b b b b b b b
  • Loading branch information
tremby committed Oct 4, 2018
1 parent 61043fb commit 7a62156
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ for (let i = 0; i < 25; i++) {
.replace(/\s{2}\r/g, ' ')
)
}
texts.push('Some text\nwith newline characters\nin it.');

describe('params', () => {
describe('indent', () => {
Expand Down Expand Up @@ -78,3 +79,14 @@ describe('lines', () => {
})
})
})

describe('newlines', () => {
it('newlines should be treated properly', () => {
assert.equal(hangingIndent(`A${' a'.repeat(50)}\nB${' b'.repeat(50)}`),
'A a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\n'
+ ' a a a a a a a a a a a\n'
+ ' B b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b\n'
+ ' b b b b b b b b b b b'
)
})
})

0 comments on commit 7a62156

Please sign in to comment.