Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Oct 3, 2019
1 parent 8d8c73c commit 6ca8275
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/babel-core/test/config-chain.js
Expand Up @@ -944,6 +944,52 @@ describe("buildConfigChain", function() {
}
});

it("should load babel.config.json", () => {
const filename = fixture("config-files", "babel-config-json", "src.js");

expect(
loadOptions({
filename,
cwd: path.dirname(filename),
}),
).toEqual({
...getDefaults(),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
});
});

it("should load babel.config.js", () => {
const filename = fixture("config-files", "babel-config-js", "src.js");

expect(
loadOptions({
filename,
cwd: path.dirname(filename),
}),
).toEqual({
...getDefaults(),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
});
});

it("should whtow if both babel.config.json and babel.config.js are used", () => {
const filename = fixture(
"config-files",
"babel-config-js-and-json",
"src.js",
);

expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Multiple configuration files found/);
});

it("should load .babelrc", () => {
const filename = fixture("config-files", "babelrc", "src.js");

Expand Down
@@ -0,0 +1,3 @@
module.exports = {
comments: true
};
@@ -0,0 +1,3 @@
{
"comments": true
}
@@ -0,0 +1,3 @@
module.exports = {
comments: true
};
@@ -0,0 +1,3 @@
{
"comments": true
}

0 comments on commit 6ca8275

Please sign in to comment.