Skip to content

Commit

Permalink
Merge pull request #188 from APshenkin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgruber authored Sep 18, 2017
2 parents 9a022a4 + 95f3221 commit 6265395
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function removeAllPropsFromObjExcept(obj, propsToKeep) {
function cleanCode(str) {
str = str
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '')
.replace(/^function\s*\(.*\)\s*{|\(.*\)\s*=>\s*{?/, '')
.replace(/^function\*?\s*\(.*\)\s*{|\(.*\)\s*=>\s*{?/, '')
.replace(/\s*\}$/, '');

const spaces = str.match(/^\n?( *)/)[1].length;
Expand Down
7 changes: 7 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ describe('Mochawesome Utils', () => {
cleanCode(fnStr).should.equal(expected);
});

it('should clean generator function syntax', () => {
fnStr = `function* () {
return true;
}`;
cleanCode(fnStr).should.equal(expected);
});

it('should clean non-standard arrow function syntax', () => {
fnStr = `() =>
{
Expand Down

0 comments on commit 6265395

Please sign in to comment.