From 21f42544ca5e8010c54c3bba60d29a15908297d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 9 Nov 2020 16:14:56 +0100 Subject: [PATCH] Fixed incorrectly implemented tests for `loadOptions` (#12301) --- packages/babel-core/test/option-manager.js | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/babel-core/test/option-manager.js b/packages/babel-core/test/option-manager.js index ecc9272754e8..75698baec824 100644 --- a/packages/babel-core/test/option-manager.js +++ b/packages/babel-core/test/option-manager.js @@ -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: [ @@ -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({ @@ -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", () => { @@ -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();