Files
test-repo/tests_integration/__tests__/support-info.js
T
Georgii Dolzhykov cf3d9f0b80 api: remove the version parameter of getSupportInfo (#7620)
* api: remove the version parameter of getSupportInfo

* add changelog entry

* remove mapDeprecated

* Update pr-7620.md

* remove the first parameter completely

* Update api.md

* add default value for opts just to be on the safe side
2020-02-23 02:47:17 +02:00

37 lines
927 B
JavaScript

"use strict";
const prettier = require("prettier/local");
const runPrettier = require("../runPrettier");
test("API getSupportInfo()", () => {
expect(getCoreInfo()).toMatchSnapshot();
});
describe("CLI --support-info", () => {
runPrettier("cli", "--support-info").test({ status: 0 });
});
function getCoreInfo() {
const supportInfo = prettier.getSupportInfo();
const languages = supportInfo.languages.reduce(
(obj, language) => ({ [language.name]: language.parsers, ...obj }),
{}
);
const options = supportInfo.options.reduce(
(obj, 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)
},
...obj
}),
{}
);
return { languages, options };
}