Files
test-repo/tests/integration/__tests__/with-parser-inference.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.7 KiB
JavaScript
Raw Normal View History

"use strict";
2020-09-18 14:05:29 +08:00
const prettier = require("prettier-local");
2022-02-10 10:12:31 +08:00
const runPrettier = require("../run-prettier.js");
describe("infers postcss parser", () => {
runPrettier("cli/with-parser-inference", ["--end-of-line", "lf", "*"]).test({
status: 0,
});
});
2018-12-19 14:03:30 +00:00
describe("infers postcss parser with --check", () => {
runPrettier("cli/with-parser-inference", ["--check", "*"]).test({
status: 0,
});
});
describe("infers postcss parser with --list-different", () => {
runPrettier("cli/with-parser-inference", ["--list-different", "*"]).test({
status: 0,
});
});
describe("infers parser from filename", () => {
test("json from .prettierrc", () => {
2021-10-04 07:46:38 +09:00
expect(prettier.format(" { } ", { filepath: "x/y/.prettierrc" })).toBe(
"{}\n"
);
});
2021-08-31 12:40:52 +08:00
test("json from .stylelintrc", () => {
2021-10-04 07:46:38 +09:00
expect(prettier.format(" { } ", { filepath: "x/y/.stylelintrc" })).toBe(
"{}\n"
);
2021-08-31 12:40:52 +08:00
});
test("yaml from .stylelintrc", () => {
expect(
prettier.format(" extends: '' ", { filepath: "x/y/.stylelintrc" })
2021-10-04 07:46:38 +09:00
).toBe('extends: ""\n');
2021-08-31 12:40:52 +08:00
});
2018-12-27 08:05:19 -05:00
test("babel from Jakefile", () => {
expect(
prettier.format("let foo = ( x = 1 ) => x", { filepath: "x/y/Jakefile" })
2021-10-04 07:46:38 +09:00
).toBe("let foo = (x = 1) => x;\n");
});
2022-02-18 08:39:12 +09:00
test("json from .swcrc", () => {
expect(
prettier.format(
`
{
"jsc": {
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
"keepClassNames": false
}
}
`,
{ filepath: "/path/to/.swcrc" }
)
).toBe(`{
"jsc": {
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
"keepClassNames": false
}
}
`);
});
});