From 110cacab191d1e1f3a55f94bc625a00e0960563a Mon Sep 17 00:00:00 2001 From: Himaja Date: Sun, 25 Oct 2015 14:13:14 -0400 Subject: [PATCH] Added a throw error block in describe incase a function with arguments is passed in describe --- spec/core/EnvSpec.js | 9 +++++++++ src/core/Env.js | 3 +++ 2 files changed, 12 insertions(+) diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index 3f0ecd02..d0d86414 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -26,6 +26,15 @@ describe("Env", function() { }); }); + describe('#describe', function () { + var spec = function(done){}; + it("throws the error", function() { + expect(function() { + env.describe('done method', spec); + }).toThrow(new Error('describe is not expecting a done parameter')); + }); + }); + it('can configure specs to throw errors on expectation failures', function() { env.throwOnExpectationFailure(true); diff --git a/src/core/Env.js b/src/core/Env.js index b70b0a06..949701d1 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -291,6 +291,9 @@ getJasmineRequireObj().Env = function(j$) { this.describe = function(description, specDefinitions) { var suite = suiteFactory(description); + if (specDefinitions.length > 0) { + throw new Error('describe is not expecting a done parameter'); + } if (currentDeclarationSuite.markedPending) { suite.pend(); }