Files
test-repo/tests/integration/__tests__/support-info.js
T

35 lines
909 B
JavaScript

import prettier from "prettier-local";
import runPrettier from "../run-prettier.js";
test("API getSupportInfo()", async () => {
expect(await getCoreInfo()).toMatchSnapshot();
});
describe("CLI --support-info", () => {
runPrettier("cli", "--support-info").test({ status: 0 });
});
async function getCoreInfo() {
const supportInfo = await prettier.getSupportInfo();
const languages = Object.fromEntries(
supportInfo.languages.map(({ name, parsers }) => [name, parsers])
);
const options = Object.fromEntries(
supportInfo.options.map((option) => [
option.name,
{
type: option.type,
default: option.default,
...(option.type === "int"
? { range: option.range }
: option.type === "choice"
? { choices: option.choices.map((choice) => choice.value) }
: null),
},
])
);
return { languages, options };
}