Skip to content

Commit

Permalink
Add tests for string quoting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ammojamo committed Mar 29, 2016
1 parent 934b22c commit 9b8cc65
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/dox.test.js
Expand Up @@ -947,5 +947,20 @@ module.exports = {
comments[0].tags[2].html.should.equal("<p>NPM:lodash.merge</p>");
done();
});
}
},

'test that quotes within strings are correctly handled': function (done) {
fixture('string-quotes.js', function (err, str){
var comments = dox.parseComments(str);
comments.length.should.equal(7);
comments[0].description.full.should.equal("<p>One</p>");
comments[1].description.full.should.equal("<p>Two</p>");
comments[2].description.full.should.equal("<p>Three</p>");
comments[3].description.full.should.equal("<p>Four</p>");
comments[4].description.full.should.equal("<p>Five</p>");
comments[5].description.full.should.equal("<p>Six</p>");
comments[6].description.full.should.equal("<p>Seven</p>");
done();
});
},
};
48 changes: 48 additions & 0 deletions test/fixtures/string-quotes.js
@@ -0,0 +1,48 @@
/**
* One
*/
function one() {
var a = "String with double quotes containing a single quote: '";
}

/**
* Two
*/
function two() {
var a = "String with double quotes containing an escaped single quote: \'";
}

/**
* Three
*/
function three() {
var a = "String with double quotes containing an escaped double quote: \"";
}

/**
* Four
*/
function four() {
var a = 'String with single quotes containing a double quote: "';
}

/**
* Five
*/
function five() {
var a = 'String with single quotes containing an escaped double quote: \"';
}

/**
* Six
*/
function six() {
var a = 'String with single quotes containing an escaped single quote: \'';
}

/**
* Seven
*/
function seven() {
var a = "Last function that should also get included";
}

0 comments on commit 9b8cc65

Please sign in to comment.