Files
test-repo/tests_integration/__tests__/doc-mark-as-root.js
T
fisker CheungandGeorgii Dolzhykov d456b158e0 Style: use object destructuring (#7325)
* Style: use object destructuring

* Update versions.js

* Update sync-flow-tests.js

* Update core.js

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-01-14 17:30:18 +02:00

34 lines
1.0 KiB
JavaScript

"use strict";
const prettier = require("prettier/local");
const docPrinter = prettier.doc.printer;
const docBuilders = prettier.doc.builders;
const { printDocToString } = docPrinter;
const { concat, hardline, literalline, trim, indent, markAsRoot } = docBuilders;
describe("markAsRoot", () => {
test.each([
[
"with hardline will insert a newline with current indentation",
concat([indent(markAsRoot(indent(hardline))), "123"]),
"\n 123"
],
[
"with literalline will insert a newline with root indentation",
concat([indent(markAsRoot(indent(literalline))), "123"]),
"\n 123"
],
[
"followed by trim will trims up to the the first column, ignoring indented root",
concat([indent(markAsRoot(indent(literalline))), trim, "123"]),
"\n123"
]
])("%s", (_, doc, expected) => {
const result = printDocToString(doc, { printWidth: 80, tabWidth: 2 });
expect(result).toBeDefined();
expect(result.formatted).toEqual(expected);
});
});