Fix --debug-print-doc (#2400)

* Add test of --debug-print-doc

See https://github.com/prettier/prettier/issues/2396

* Pass test of --debug-print-doc

See https://github.com/prettier/prettier/issues/2396
master
Joseph Frazier 2017-07-05 12:25:51 -04:00 committed by Christopher Chedeau
parent 8fcd667200
commit 16bc297572
2 changed files with 14 additions and 1 deletions

View File

@ -154,7 +154,7 @@ const options = {
function format(input, opt) {
if (argv["debug-print-doc"]) {
const doc = prettier.__debug.printToDoc(input, opt);
return prettier.__debug.formatDoc(doc);
return { formatted: prettier.__debug.formatDoc(doc) };
}
if (argv["debug-check"]) {

View File

@ -0,0 +1,13 @@
"use strict";
const runPrettier = require("../runPrettier");
test("prints doc with --debug-print-doc", () => {
const result = runPrettier("cli/with-shebang", ["--debug-print-doc"], {
input: "0"
});
expect(result.stdout).toEqual('["0", ";", hardline, breakParent];\n');
expect(result.stderr).toEqual("");
expect(result.status).toEqual(0);
});