Files
test-repo/tests/integration/__tests__/resolve-config-file.js
T

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

25 lines
942 B
JavaScript
Raw Normal View History

2023-09-06 14:54:36 +08:00
import url from "node:url";
2022-07-20 23:18:24 +08:00
import prettier from "../../config/prettier-entry.js";
2020-08-21 09:43:24 +08:00
test("API resolveConfigFile", async () => {
const result = await prettier.resolveConfigFile();
2023-09-04 19:59:42 +08:00
expect(result).toEqual(
url.fileURLToPath(new URL("../../../prettier.config.js", import.meta.url)),
2023-09-04 19:59:42 +08:00
);
});
test("API resolveConfigFile accepts path or URL", async () => {
const fileUrl = new URL("../cli/config/filepath/foo.js", import.meta.url);
2023-09-06 14:54:36 +08:00
const expectedConfigFilePath = url.fileURLToPath(
2023-09-04 19:59:42 +08:00
new URL("./.prettierrc", fileUrl),
);
const resultByUrl = await prettier.resolveConfigFile(fileUrl);
const resultByUrlHref = await prettier.resolveConfigFile(fileUrl.href);
const resultByPath = await prettier.resolveConfigFile(
2023-09-06 14:54:36 +08:00
url.fileURLToPath(fileUrl),
2023-09-04 19:59:42 +08:00
);
expect(resultByUrl).toEqual(expectedConfigFilePath);
expect(resultByUrlHref).toEqual(expectedConfigFilePath);
expect(resultByPath).toEqual(expectedConfigFilePath);
2020-08-21 09:43:24 +08:00
});