From 03998c1b2005d1aeef80ec3ee3bb457981fcc8ba Mon Sep 17 00:00:00 2001 From: Gregg Van Hove Date: Tue, 5 Jun 2018 17:12:43 -0700 Subject: [PATCH] Add documentation for more public functions on Env - Fixes #1565 --- lib/jasmine-core/jasmine.js | 59 +++++++++++++++++++++++++++++++------ src/core/Env.js | 59 +++++++++++++++++++++++++++++++------ 2 files changed, 100 insertions(+), 18 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 8d4d2728..4be44b0f 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -797,7 +797,7 @@ getJasmineRequireObj().Env = function(j$) { var throwOnExpectationFailure = false; var stopOnSpecFailure = false; var random = true; - var hidingDisabled = false; + var hidingDisabled = false; var seed = null; var handlingLoadErrors = true; var hasFailures = false; @@ -959,6 +959,13 @@ getJasmineRequireObj().Env = function(j$) { var maximumSpecCallbackDepth = 20; var currentSpecCallbackDepth = 0; + /** + * Sets whether Jasmine should throw an Error when an expectation fails. + * This causes a spec to only have one expectation failure. + * @name throwOnExpectationFailure + * @function + * @param {Boolean} value Whether to throw when a expectation fails + */ this.throwOnExpectationFailure = function(value) { throwOnExpectationFailure = !!value; }; @@ -967,6 +974,12 @@ getJasmineRequireObj().Env = function(j$) { return throwOnExpectationFailure; }; + /** + * Set whether to stop suite execution when a spec fails + * @name stopOnSpecFailure + * @function + * @param {Boolean} value Whether to stop suite execution when a spec fails + */ this.stopOnSpecFailure = function(value) { stopOnSpecFailure = !!value; }; @@ -975,22 +988,26 @@ getJasmineRequireObj().Env = function(j$) { return stopOnSpecFailure; }; + /** + * Set whether to randomize test execution order + * @name randomizeTests + * @function + * @param {Boolean} value Whether to randomize execution order + */ this.randomizeTests = function(value) { random = !!value; }; - this.hidingDisabled = function(value) { - return hidingDisabled; - }; - - this.hideDisabled = function(value) { - hidingDisabled = !!value; - }; - this.randomTests = function() { return random; }; + /** + * Set the random number seed for spec randomization + * @name seed + * @function + * @param {Number} value The seed value + */ this.seed = function(value) { if (value) { seed = value; @@ -998,6 +1015,18 @@ getJasmineRequireObj().Env = function(j$) { return seed; }; + this.hidingDisabled = function(value) { + return hidingDisabled; + }; + + /** + * @name hideDisabled + * @function + */ + this.hideDisabled = function(value) { + hidingDisabled = !!value; + }; + this.deprecated = function(deprecation) { var runnable = currentRunnable() || topSuite; runnable.addDeprecationWarning(deprecation); @@ -1225,10 +1254,22 @@ getJasmineRequireObj().Env = function(j$) { reporter.addReporter(reporterToAdd); }; + /** + * Provide a fallback reporter if no other reporters have been specified. + * @name provideFallbackReporter + * @function + * @param {Reporter} reporterToAdd The reporter + * @see custom_reporter + */ this.provideFallbackReporter = function(reporterToAdd) { reporter.provideFallbackReporter(reporterToAdd); }; + /** + * Clear all registered reporters + * @name clearReporters + * @function + */ this.clearReporters = function() { reporter.clearReporters(); }; diff --git a/src/core/Env.js b/src/core/Env.js index b109f797..f6631473 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -26,7 +26,7 @@ getJasmineRequireObj().Env = function(j$) { var throwOnExpectationFailure = false; var stopOnSpecFailure = false; var random = true; - var hidingDisabled = false; + var hidingDisabled = false; var seed = null; var handlingLoadErrors = true; var hasFailures = false; @@ -188,6 +188,13 @@ getJasmineRequireObj().Env = function(j$) { var maximumSpecCallbackDepth = 20; var currentSpecCallbackDepth = 0; + /** + * Sets whether Jasmine should throw an Error when an expectation fails. + * This causes a spec to only have one expectation failure. + * @name throwOnExpectationFailure + * @function + * @param {Boolean} value Whether to throw when a expectation fails + */ this.throwOnExpectationFailure = function(value) { throwOnExpectationFailure = !!value; }; @@ -196,6 +203,12 @@ getJasmineRequireObj().Env = function(j$) { return throwOnExpectationFailure; }; + /** + * Set whether to stop suite execution when a spec fails + * @name stopOnSpecFailure + * @function + * @param {Boolean} value Whether to stop suite execution when a spec fails + */ this.stopOnSpecFailure = function(value) { stopOnSpecFailure = !!value; }; @@ -204,22 +217,26 @@ getJasmineRequireObj().Env = function(j$) { return stopOnSpecFailure; }; + /** + * Set whether to randomize test execution order + * @name randomizeTests + * @function + * @param {Boolean} value Whether to randomize execution order + */ this.randomizeTests = function(value) { random = !!value; }; - this.hidingDisabled = function(value) { - return hidingDisabled; - }; - - this.hideDisabled = function(value) { - hidingDisabled = !!value; - }; - this.randomTests = function() { return random; }; + /** + * Set the random number seed for spec randomization + * @name seed + * @function + * @param {Number} value The seed value + */ this.seed = function(value) { if (value) { seed = value; @@ -227,6 +244,18 @@ getJasmineRequireObj().Env = function(j$) { return seed; }; + this.hidingDisabled = function(value) { + return hidingDisabled; + }; + + /** + * @name hideDisabled + * @function + */ + this.hideDisabled = function(value) { + hidingDisabled = !!value; + }; + this.deprecated = function(deprecation) { var runnable = currentRunnable() || topSuite; runnable.addDeprecationWarning(deprecation); @@ -454,10 +483,22 @@ getJasmineRequireObj().Env = function(j$) { reporter.addReporter(reporterToAdd); }; + /** + * Provide a fallback reporter if no other reporters have been specified. + * @name provideFallbackReporter + * @function + * @param {Reporter} reporterToAdd The reporter + * @see custom_reporter + */ this.provideFallbackReporter = function(reporterToAdd) { reporter.provideFallbackReporter(reporterToAdd); }; + /** + * Clear all registered reporters + * @name clearReporters + * @function + */ this.clearReporters = function() { reporter.clearReporters(); };