forked from prettier/prettier
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththird-party.js
53 lines (49 loc) · 1.42 KB
/
third-party.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";
const path = require("path");
const { thirdParty } = require("../env");
const { cosmiconfig, cosmiconfigSync } = require(thirdParty);
// This don't has to be the same result as `prettier.resolveConfig`,
// Because we are testing with default `cosmiconfigOptions`
describe("cosmiconfig", () => {
const configs = [
{
title: "prettier.config.js",
dirname: path.join(__dirname, "../cli/config/js/"),
file: path.join(__dirname, "../cli/config/js/prettier.config.js"),
value: {
endOfLine: "auto",
tabWidth: 8,
},
},
{
title: "package.json",
dirname: path.join(__dirname, "../cli/config/package/"),
file: path.join(__dirname, "../cli/config/package/package.json"),
value: {
tabWidth: 3,
overrides: [
{
files: "*.ts",
options: {
tabWidth: 5,
},
},
],
},
},
];
for (const { title, dirname, file, value } of configs) {
test(`async version ${title}`, async () => {
const { config, filepath } = await cosmiconfig("prettier").search(
dirname
);
expect(config).toEqual(value);
expect(filepath).toBe(file);
});
test(`sync version ${title}`, () => {
const { config, filepath } = cosmiconfigSync("prettier").search(dirname);
expect(config).toEqual(value);
expect(filepath).toBe(file);
});
}
});