option-manager.js (babel-7.12.6) | : | option-manager.js (babel-7.12.7) | ||
---|---|---|---|---|
skipping to change at line 65 | skipping to change at line 65 | |||
presets: [ | presets: [ | |||
"./fixtures/option-manager/babel-plugin-foo", | "./fixtures/option-manager/babel-plugin-foo", | |||
"./fixtures/option-manager/babel-preset-bar", | "./fixtures/option-manager/babel-preset-bar", | |||
{ useSpread: true }, | { useSpread: true }, | |||
], | ], | |||
}); | }); | |||
}).toThrowErrorMatchingSnapshot(); | }).toThrowErrorMatchingSnapshot(); | |||
}); | }); | |||
it("should not throw when a preset string followed by valid preset object", () => { | it("should not throw when a preset string followed by valid preset object", () => { | |||
const { plugin } = makePlugin("my-plugin"); | const { plugin } = makePlugin(); | |||
expect( | expect( | |||
loadOptions({ | loadOptions({ | |||
presets: [ | presets: [ | |||
"@babel/env", | "@babel/env", | |||
{ plugins: [[plugin, undefined, "my-plugin"]] }, | { plugins: [[plugin, undefined, "my-plugin"]] }, | |||
], | ], | |||
}), | }), | |||
).toBeTruthy(); | ).toBeTruthy(); | |||
}); | }); | |||
it("should throw if a plugin is repeated, with information about the repeate | it("should throw if a plugin name is repeated, with information about the re | |||
d plugin", () => { | peated plugin", () => { | |||
const { calls, plugin } = makePlugin("my-plugin"); | const { calls, plugin } = makePlugin(); | |||
expect(() => { | expect(() => { | |||
loadOptions({ | loadOptions({ | |||
plugins: [ | plugins: [ | |||
[plugin, undefined, "my-plugin"], | [plugin, undefined, "my-plugin"], | |||
[plugin, undefined, "my-plugin"], | [plugin, undefined, "my-plugin"], | |||
], | ], | |||
}); | }); | |||
}).toThrow( | }).toThrow( | |||
/Duplicate plugin\/preset detected.*Duplicates detected are.*my-plugin.* my-plugin/ms, | /Duplicate plugin\/preset detected.*Duplicates detected are.*my-plugin.* my-plugin/ms, | |||
skipping to change at line 104 | skipping to change at line 104 | |||
expect(() => { | expect(() => { | |||
loadOptions({ | loadOptions({ | |||
plugins: [[plugin, null]], | plugins: [[plugin, null]], | |||
}); | }); | |||
}).toThrow(".plugins[0][1] must be an object, false, or undefined"); | }).toThrow(".plugins[0][1] must be an object, false, or undefined"); | |||
expect(calls).toEqual([]); | expect(calls).toEqual([]); | |||
}); | }); | |||
it("should not throw if a repeated plugin has a different name", () => { | it("should not throw if a repeated plugin has a different name", () => { | |||
const { calls: calls1, plugin: plugin1 } = makePlugin(); | const { calls, plugin } = makePlugin(); | |||
const { calls: calls2, plugin: plugin2 } = makePlugin(); | ||||
loadOptions({ | loadOptions({ | |||
plugins: [ | plugins: [ | |||
[plugin1, { arg: 1 }], | [plugin, { arg: 1 }], | |||
[plugin2, { arg: 2 }, "some-name"], | [plugin, { arg: 2 }, "some-name"], | |||
], | ], | |||
}); | }); | |||
expect(calls1).toEqual([{ arg: 1 }]); | expect(calls).toEqual([{ arg: 1 }, { arg: 2 }]); | |||
expect(calls2).toEqual([{ arg: 2 }]); | ||||
}); | }); | |||
it("should merge .env[] plugins with parent presets", () => { | it("should merge .env[] plugins with parent presets", () => { | |||
const { calls: calls1, plugin: plugin1 } = makePlugin(); | const { calls: calls1, plugin: plugin1 } = makePlugin(); | |||
const { calls: calls2, plugin: plugin2 } = makePlugin(); | const { calls: calls2, plugin: plugin2 } = makePlugin(); | |||
loadOptions({ | loadOptions({ | |||
envName: "test", | envName: "test", | |||
plugins: [[plugin1, { arg: 1 }]], | plugins: [[plugin1, { arg: 1 }]], | |||
env: { | env: { | |||
skipping to change at line 149 | skipping to change at line 147 | |||
expect(() => { | expect(() => { | |||
loadOptions({ | loadOptions({ | |||
presets: [preset, preset], | presets: [preset, preset], | |||
}); | }); | |||
}).toThrow(/Duplicate plugin\/preset detected/); | }).toThrow(/Duplicate plugin\/preset detected/); | |||
expect(calls).toEqual([]); | expect(calls).toEqual([]); | |||
}); | }); | |||
it("should not throw if a repeated preset has a different name", () => { | it("should not throw if a repeated preset has a different name", () => { | |||
const { calls: calls1, plugin: preset1 } = makePlugin(); | const { calls, plugin: preset } = makePlugin(); | |||
const { calls: calls2, plugin: preset2 } = makePlugin(); | ||||
loadOptions({ | loadOptions({ | |||
presets: [ | presets: [ | |||
[preset1, { arg: 1 }], | [preset, { arg: 1 }], | |||
[preset2, { arg: 2 }, "some-name"], | [preset, { arg: 2 }, "some-name"], | |||
], | ], | |||
}); | }); | |||
expect(calls1).toEqual([{ arg: 1 }]); | expect(calls).toEqual([{ arg: 1 }, { arg: 2 }]); | |||
expect(calls2).toEqual([{ arg: 2 }]); | ||||
}); | }); | |||
it("should merge .env[] presets with parent presets", () => { | it("should merge .env[] presets with parent presets", () => { | |||
const { calls: calls1, plugin: preset1 } = makePlugin(); | const { calls: calls1, plugin: preset1 } = makePlugin(); | |||
const { calls: calls2, plugin: preset2 } = makePlugin(); | const { calls: calls2, plugin: preset2 } = makePlugin(); | |||
loadOptions({ | loadOptions({ | |||
envName: "test", | envName: "test", | |||
presets: [[preset1, { arg: 1 }]], | presets: [[preset1, { arg: 1 }]], | |||
env: { | env: { | |||
test: { | test: { | |||
End of changes. 8 change blocks. | ||||
16 lines changed or deleted | 12 lines changed or added |