From ce6f67216e2c90d1ecae758238cde2b4507984fe Mon Sep 17 00:00:00 2001 From: Mauro Bringolf Date: Sun, 14 May 2017 16:21:37 +0200 Subject: [PATCH] Add test cases for bad options in babel-preset-es2015 (#5720) * Added testcases for bad 'spec' or 'module' option * Corrected typo in test description --- packages/babel-preset-es2015/test/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/babel-preset-es2015/test/index.js b/packages/babel-preset-es2015/test/index.js index 99ac458986..ffb1683dd3 100644 --- a/packages/babel-preset-es2015/test/index.js +++ b/packages/babel-preset-es2015/test/index.js @@ -18,6 +18,14 @@ describe("es2015 preset", function () { }); }); + describe("spec", function () { + it("throws on non-boolean value", function () { + expect(function () { + es2015(null, { spec: 1 }); + }).to.throw(/must be a boolean/); + }); + }); + describe("modules", function () { it("doesn't throw when passing one false", function () { expect(function () { @@ -42,6 +50,12 @@ describe("es2015 preset", function () { es2015(null, { modules: "systemjs" }); }).not.to.throw(); }); + + it("throws when passing neither false nor one of: 'commonjs', 'amd', 'umd', 'systemjs'", function () { + expect(function () { + es2015(null, { modules: 1 }); + }).to.throw(); + }); }); }); });