Skip to content

Commit

Permalink
Test bundled cosmiconfig (#8262)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 8, 2020
1 parent 3f4da31 commit da44da6
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests_integration/__tests__/third-party.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
});
}
});

0 comments on commit da44da6

Please sign in to comment.