Skip to content

Commit

Permalink
fix(babel-plugin-espower): do not include comments in one-line format…
Browse files Browse the repository at this point in the history
… assertion

refs: avajs/ava#538
  • Loading branch information
twada committed Feb 14, 2016
1 parent 1af784b commit c5af6c5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/babel-assertion-visitor.js
Expand Up @@ -133,7 +133,7 @@ BabelAssertionVisitor.prototype.isGeneratedNode = function (nodePath) {
// internal

BabelAssertionVisitor.prototype.generateCanonicalCode = function (node) {
var gen = new babelgen.CodeGenerator(node, { concise: true });
var gen = new babelgen.CodeGenerator(node, { concise: true, comments: false });
return gen.generate().code;
};

Expand Down
21 changes: 21 additions & 0 deletions test/fixtures/CommentsInAssertion/expected.js
@@ -0,0 +1,21 @@
'use strict';

var _powerAssertRecorder = function () { function PowerAssertRecorder() { this.captured = []; } PowerAssertRecorder.prototype._capt = function _capt(value, espath) { this.captured.push({ value: value, espath: espath }); return value; }; PowerAssertRecorder.prototype._expr = function _expr(value, source) { return { powerAssertContext: { value: value, events: this.captured }, source: source }; }; return PowerAssertRecorder; }(),
_rec = new _powerAssertRecorder(),
_rec2 = new _powerAssertRecorder();

assert.equal(
// first comment
_rec._expr(_rec._capt(str, 'arguments/0'), {
content: 'assert.equal(str, anotherStr)',
filepath: 'test/fixtures/CommentsInAssertion/fixture.js',
line: 3
}),
// second comment
_rec2._expr(_rec2._capt(anotherStr, 'arguments/1'), {
content: 'assert.equal(str, anotherStr)',
filepath: 'test/fixtures/CommentsInAssertion/fixture.js',
line: 3
})
// last comment
);
9 changes: 9 additions & 0 deletions test/fixtures/CommentsInAssertion/fixture.js
@@ -0,0 +1,9 @@
'use strict';

assert.equal(
// first comment
str,
// second comment
anotherStr
// last comment
);
1 change: 1 addition & 0 deletions test/test.js
Expand Up @@ -64,4 +64,5 @@ describe('babel-plugin-espower', function () {
})
]
});
testTransform('CommentsInAssertion');
});

0 comments on commit c5af6c5

Please sign in to comment.