From 4240b3514b75b9d13a9be73daab4804105caedb1 Mon Sep 17 00:00:00 2001 From: ksvitkovsky Date: Thu, 10 Aug 2017 22:58:30 +0400 Subject: [PATCH] Check runnable instead of suite --- src/core/Env.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/Env.js b/src/core/Env.js index 86e86ac4..6ec112bd 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -384,8 +384,8 @@ getJasmineRequireObj().Env = function(j$) { } }; - function ensureIsNotNested(method, currentSuite) { - if (currentSuite !== undefined) { + function ensureIsNotNested(method, runnable) { + if (runnable !== null && runnable !== undefined) { throw new Error('\'' + method + '\' should only be used in \'describe\' function'); } } @@ -405,7 +405,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.describe = function(description, specDefinitions) { - ensureIsNotNested('describe', currentSuite()); + ensureIsNotNested('describe', currentRunnable()); ensureIsFunction(specDefinitions, 'describe'); var suite = suiteFactory(description); if (specDefinitions.length > 0) { @@ -419,7 +419,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.xdescribe = function(description, specDefinitions) { - ensureIsNotNested('xdescribe', currentSuite()); + ensureIsNotNested('xdescribe', currentRunnable()); ensureIsFunction(specDefinitions, 'xdescribe'); var suite = suiteFactory(description); suite.pend(); @@ -430,7 +430,7 @@ getJasmineRequireObj().Env = function(j$) { var focusedRunnables = []; this.fdescribe = function(description, specDefinitions) { - ensureIsNotNested('fdescribe', currentSuite()); + ensureIsNotNested('fdescribe', currentRunnable()); ensureIsFunction(specDefinitions, 'fdescribe'); var suite = suiteFactory(description); suite.isFocused = true; @@ -528,7 +528,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.it = function(description, fn, timeout) { - ensureIsNotNested('it', currentSuite()); + ensureIsNotNested('it', currentRunnable()); // it() sometimes doesn't have a fn argument, so only check the type if // it's given. if (arguments.length > 1 && typeof fn !== 'undefined') { @@ -543,7 +543,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.xit = function(description, fn, timeout) { - ensureIsNotNested('xit', currentSuite()); + ensureIsNotNested('xit', currentRunnable()); // xit(), like it(), doesn't always have a fn argument, so only check the // type when needed. if (arguments.length > 1 && typeof fn !== 'undefined') { @@ -555,7 +555,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.fit = function(description, fn, timeout){ - ensureIsNotNested('fit', currentSuite()); + ensureIsNotNested('fit', currentRunnable()); ensureIsFunctionOrAsync(fn, 'fit'); var spec = specFactory(description, fn, currentDeclarationSuite, timeout); currentDeclarationSuite.addChild(spec); @@ -573,7 +573,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.beforeEach = function(beforeEachFunction, timeout) { - ensureIsNotNested('beforeEach', currentSuite()); + ensureIsNotNested('beforeEach', currentRunnable()); ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach'); currentDeclarationSuite.beforeEach({ fn: beforeEachFunction, @@ -582,7 +582,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.beforeAll = function(beforeAllFunction, timeout) { - ensureIsNotNested('beforeAll', currentSuite()); + ensureIsNotNested('beforeAll', currentRunnable()); ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll'); currentDeclarationSuite.beforeAll({ fn: beforeAllFunction, @@ -591,7 +591,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.afterEach = function(afterEachFunction, timeout) { - ensureIsNotNested('afterEach', currentSuite()); + ensureIsNotNested('afterEach', currentRunnable()); ensureIsFunctionOrAsync(afterEachFunction, 'afterEach'); afterEachFunction.isCleanup = true; currentDeclarationSuite.afterEach({ @@ -601,7 +601,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.afterAll = function(afterAllFunction, timeout) { - ensureIsNotNested('afterAll', currentSuite()); + ensureIsNotNested('afterAll', currentRunnable()); ensureIsFunctionOrAsync(afterAllFunction, 'afterAll'); currentDeclarationSuite.afterAll({ fn: afterAllFunction,