Skip to content

Commit 32e4120

Browse files
committed
test: @putout/operator-add-args: VariableDeclaration
1 parent 9e468aa commit 32e4120

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

packages/operator-add-args/lib/add-args.spec.js

+34-9
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ test('putout: operator: add-args: MemberExpression', (t) => {
452452
t.end();
453453
});
454454

455-
test('putout: operator: add-args: VariableDeclaration', (t) => {
455+
test('putout: operator: add-args: AssignmentExpression: no', (t) => {
456456
const args = {
457457
process: ['{process}', 'module.exports.__a = (__args) => __body'],
458458
};
@@ -471,14 +471,7 @@ test('putout: operator: add-args: VariableDeclaration', (t) => {
471471
],
472472
});
473473

474-
const expected = montag`
475-
module.exports.VariableDeclaration = (path) => {
476-
const {PUTOUT_PROGRESS_BAR} = process.env;
477-
const {stderr} = process;
478-
};
479-
`;
480-
481-
t.equal(code, expected);
474+
t.equal(code, source);
482475
t.end();
483476
});
484477

@@ -557,3 +550,35 @@ test('putout: operator: add-args: FunctionDeclaration', (t) => {
557550
t.end();
558551
});
559552

553+
test('putout: operator: add-args: VariableDeclaration', (t) => {
554+
const args = {
555+
traverse: ['{traverse}', 'const __ = __'],
556+
};
557+
558+
const source = montag`
559+
const CallExpression = {
560+
print(path, {indent, print, maybe}) {
561+
traverse(path.get('callee'));
562+
}
563+
};
564+
`;
565+
566+
const {code} = putout(source, {
567+
fixCount: 1,
568+
printer: 'putout',
569+
plugins: [
570+
['add-args', addArgs(args)],
571+
],
572+
});
573+
574+
const expected = montag`
575+
const CallExpression = {
576+
print(path, {indent, print, maybe, traverse}) {
577+
traverse(path.get('callee'));
578+
},
579+
};\n
580+
`;
581+
582+
t.equal(code, expected);
583+
t.end();
584+
});

0 commit comments

Comments
 (0)