Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[jest-docblock] remove leading newlines from parswWithComments().comm…
…ents
  • Loading branch information
samouri committed Oct 6, 2017
commit 50caa92ee85971309d4a4ca325c00ff2b7bc548a
15 changes: 15 additions & 0 deletions packages/jest-docblock/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,21 @@ describe('docblock', () => {
);
});

it('removes leading newlines in multiline comments from docblock', () => {
const code =
'/**' +
os.EOL +
' * @snailcode' +
os.EOL +
' *' +
os.EOL +
' * hello world' +
os.EOL +
' */';

expect(docblock.parseWithComments(code).comments).toEqual(' hello world');
});

it('extracts comments from beginning and end of docblock', () => {
const code =
'/**' +
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-docblock/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export function parseWithComments(
docblock = docblock.replace(ltrimNewlineRe, '').replace(rtrimRe, '');

const result = Object.create(null);
const comments = docblock.replace(propertyRe, '');
const comments = docblock
.replace(propertyRe, '')
.replace(ltrimNewlineRe, '')
.replace(rtrimRe, '');

let match;
while ((match = propertyRe.exec(docblock))) {
Expand Down