Skip to content

Commit

Permalink
fix(jsdoc): reset backTickParserAdapter correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Apr 26, 2017
1 parent a96faaa commit a82ea9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jsdoc/services/parser-adapters/backtick-parser-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/
module.exports = function backTickParserAdapter() {
return {
init: function() {},
init: function() {
this.inCode = false;
},
nextLine: function(line, lineNumber) {
const CODE_FENCE = /^\s*```(?!.*```)/;
if ( CODE_FENCE.test(line) ) {
Expand Down
25 changes: 25 additions & 0 deletions jsdoc/services/parser-adapters/backtick-parser-adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,29 @@ describe('backTickParserAdapter', function() {
adapter.nextLine(lines[8], 8);
expect(adapter.parseForTags()).toBeTruthy();
});

it('should reset on each run', () => {
const adapter = backTickParserAdapterFactory();
const lines = [
'@a some text',
'```',
'missing end tick'
];

adapter.init && adapter.init(lines, new TagCollection());
adapter.nextLine(lines[0], 0);
expect(adapter.parseForTags()).toBeTruthy();
adapter.nextLine(lines[1], 1);
expect(adapter.parseForTags()).toBeFalsy();
adapter.nextLine(lines[2], 2);
expect(adapter.parseForTags()).toBeFalsy();

adapter.init && adapter.init(lines, new TagCollection());
adapter.nextLine(lines[0], 0);
expect(adapter.parseForTags()).toBeTruthy();
adapter.nextLine(lines[1], 1);
expect(adapter.parseForTags()).toBeFalsy();
adapter.nextLine(lines[2], 2);
expect(adapter.parseForTags()).toBeFalsy();
});
});

0 comments on commit a82ea9a

Please sign in to comment.