Skip to content

Commit

Permalink
Fixed incorrectly implemented tests for loadOptions (#12301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Nov 9, 2020
1 parent ad8a4d6 commit 21f4254
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions packages/babel-core/test/option-manager.js
Expand Up @@ -62,7 +62,7 @@ describe("option-manager", () => {
});

it("should not throw when a preset string followed by valid preset object", () => {
const { plugin } = makePlugin("my-plugin");
const { plugin } = makePlugin();
expect(
loadOptions({
presets: [
Expand All @@ -73,8 +73,8 @@ describe("option-manager", () => {
).toBeTruthy();
});

it("should throw if a plugin is repeated, with information about the repeated plugin", () => {
const { calls, plugin } = makePlugin("my-plugin");
it("should throw if a plugin name is repeated, with information about the repeated plugin", () => {
const { calls, plugin } = makePlugin();

expect(() => {
loadOptions({
Expand All @@ -101,17 +101,15 @@ describe("option-manager", () => {
});

it("should not throw if a repeated plugin has a different name", () => {
const { calls: calls1, plugin: plugin1 } = makePlugin();
const { calls: calls2, plugin: plugin2 } = makePlugin();
const { calls, plugin } = makePlugin();

loadOptions({
plugins: [
[plugin1, { arg: 1 }],
[plugin2, { arg: 2 }, "some-name"],
[plugin, { arg: 1 }],
[plugin, { arg: 2 }, "some-name"],
],
});
expect(calls1).toEqual([{ arg: 1 }]);
expect(calls2).toEqual([{ arg: 2 }]);
expect(calls).toEqual([{ arg: 1 }, { arg: 2 }]);
});

it("should merge .env[] plugins with parent presets", () => {
Expand Down Expand Up @@ -146,17 +144,15 @@ describe("option-manager", () => {
});

it("should not throw if a repeated preset has a different name", () => {
const { calls: calls1, plugin: preset1 } = makePlugin();
const { calls: calls2, plugin: preset2 } = makePlugin();
const { calls, plugin: preset } = makePlugin();

loadOptions({
presets: [
[preset1, { arg: 1 }],
[preset2, { arg: 2 }, "some-name"],
[preset, { arg: 1 }],
[preset, { arg: 2 }, "some-name"],
],
});
expect(calls1).toEqual([{ arg: 1 }]);
expect(calls2).toEqual([{ arg: 2 }]);
expect(calls).toEqual([{ arg: 1 }, { arg: 2 }]);
});
it("should merge .env[] presets with parent presets", () => {
const { calls: calls1, plugin: preset1 } = makePlugin();
Expand Down

0 comments on commit 21f4254

Please sign in to comment.