Add explicit docs for the callback function passed to it etc.

This commit is contained in:
Gregg Van Hove
2017-08-08 17:28:36 -07:00
parent 9811ff71d2
commit 80dba1138a
2 changed files with 49 additions and 25 deletions

View File

@@ -2599,15 +2599,19 @@ getJasmineRequireObj().matchersUtil = function(j$) {
// Recursively compare objects and arrays. // Recursively compare objects and arrays.
// Compare array lengths to determine if a deep comparison is necessary. // Compare array lengths to determine if a deep comparison is necessary.
if (className == '[object Array]') { if (className == '[object Array]') {
size = a.length; var aLength = a.length;
if (size !== b.length) { var bLength = b.length;
diffBuilder.record(a, b);
return false;
}
for (i = 0; i < size; i++) { diffBuilder.withPath('length', function() {
if (aLength !== bLength) {
diffBuilder.record(aLength, bLength);
result = false;
}
});
for (i = 0; i < aLength || i < bLength; i++) {
diffBuilder.withPath(i, function() { diffBuilder.withPath(i, function() {
result = eq(a[i], b[i], aStack, bStack, customTesters, diffBuilder) && result; result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
}); });
} }
if (!result) { if (!result) {
@@ -4274,6 +4278,16 @@ getJasmineRequireObj().ReportDispatcher = function() {
getJasmineRequireObj().interface = function(jasmine, env) { getJasmineRequireObj().interface = function(jasmine, env) {
var jasmineInterface = { var jasmineInterface = {
/**
* Callback passed to parts of the Jasmine base interface.
*
* By default Jasmine assumes this function completes synchronously.
* If you have code that you need to test asynchronously, you can declare that you receive a `done` callback, return a Promise, or use the `async` keyword if it is supported in your environment.
* @callback implementationCallback
* @param {Function} done Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
*/
/** /**
* Create a group of specs (often called a suite). * Create a group of specs (often called a suite).
* *
@@ -4325,7 +4339,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of what this spec is checking * @param {String} description Textual description of what this spec is checking
* @param {Function} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`. * @param {implementationCallback} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
*/ */
it: function() { it: function() {
@@ -4340,7 +4354,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of what this spec is checking. * @param {String} description Textual description of what this spec is checking.
* @param {Function} [testFunction] Function that contains the code of your test. Will not be executed. * @param {implementationCallback} [testFunction] Function that contains the code of your test. Will not be executed.
*/ */
xit: function() { xit: function() {
return env.xit.apply(env, arguments); return env.xit.apply(env, arguments);
@@ -4354,7 +4368,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of what this spec is checking. * @param {String} description Textual description of what this spec is checking.
* @param {Function} testFunction Function that contains the code of your test. * @param {implementationCallback} testFunction Function that contains the code of your test.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
*/ */
fit: function() { fit: function() {
@@ -4366,7 +4380,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name beforeEach * @name beforeEach
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to setup your specs. * @param {implementationCallback} [function] Function that contains the code to setup your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach.
*/ */
beforeEach: function() { beforeEach: function() {
@@ -4378,7 +4392,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name afterEach * @name afterEach
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to teardown your specs. * @param {implementationCallback} [function] Function that contains the code to teardown your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach.
*/ */
afterEach: function() { afterEach: function() {
@@ -4392,7 +4406,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name beforeAll * @name beforeAll
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to setup your specs. * @param {implementationCallback} [function] Function that contains the code to setup your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll.
*/ */
beforeAll: function() { beforeAll: function() {
@@ -4400,13 +4414,13 @@ getJasmineRequireObj().interface = function(jasmine, env) {
}, },
/** /**
* Run some shared teardown once before all of the specs in the {@link describe} are run. * Run some shared teardown once after all of the specs in the {@link describe} are run.
* *
* _Note:_ Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail. * _Note:_ Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
* @name afterAll * @name afterAll
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to teardown your specs. * @param {implementationCallback} [function] Function that contains the code to teardown your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll.
*/ */
afterAll: function() { afterAll: function() {

View File

@@ -1,5 +1,15 @@
getJasmineRequireObj().interface = function(jasmine, env) { getJasmineRequireObj().interface = function(jasmine, env) {
var jasmineInterface = { var jasmineInterface = {
/**
* Callback passed to parts of the Jasmine base interface.
*
* By default Jasmine assumes this function completes synchronously.
* If you have code that you need to test asynchronously, you can declare that you receive a `done` callback, return a Promise, or use the `async` keyword if it is supported in your environment.
* @callback implementationCallback
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
*/
/** /**
* Create a group of specs (often called a suite). * Create a group of specs (often called a suite).
* *
@@ -8,7 +18,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of the group * @param {String} description Textual description of the group
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
*/ */
describe: function(description, specDefinitions) { describe: function(description, specDefinitions) {
return env.describe(description, specDefinitions); return env.describe(description, specDefinitions);
@@ -22,7 +32,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of the group * @param {String} description Textual description of the group
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
*/ */
xdescribe: function(description, specDefinitions) { xdescribe: function(description, specDefinitions) {
return env.xdescribe(description, specDefinitions); return env.xdescribe(description, specDefinitions);
@@ -37,7 +47,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of the group * @param {String} description Textual description of the group
* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
*/ */
fdescribe: function(description, specDefinitions) { fdescribe: function(description, specDefinitions) {
return env.fdescribe(description, specDefinitions); return env.fdescribe(description, specDefinitions);
@@ -51,7 +61,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of what this spec is checking * @param {String} description Textual description of what this spec is checking
* @param {Function} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`. * @param {implementationCallback} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
*/ */
it: function() { it: function() {
@@ -66,7 +76,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of what this spec is checking. * @param {String} description Textual description of what this spec is checking.
* @param {Function} [testFunction] Function that contains the code of your test. Will not be executed. * @param {implementationCallback} [testFunction] Function that contains the code of your test. Will not be executed.
*/ */
xit: function() { xit: function() {
return env.xit.apply(env, arguments); return env.xit.apply(env, arguments);
@@ -80,7 +90,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @function * @function
* @global * @global
* @param {String} description Textual description of what this spec is checking. * @param {String} description Textual description of what this spec is checking.
* @param {Function} testFunction Function that contains the code of your test. * @param {implementationCallback} testFunction Function that contains the code of your test.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
*/ */
fit: function() { fit: function() {
@@ -92,7 +102,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name beforeEach * @name beforeEach
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to setup your specs. * @param {implementationCallback} [function] Function that contains the code to setup your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach.
*/ */
beforeEach: function() { beforeEach: function() {
@@ -104,7 +114,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name afterEach * @name afterEach
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to teardown your specs. * @param {implementationCallback} [function] Function that contains the code to teardown your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach.
*/ */
afterEach: function() { afterEach: function() {
@@ -118,7 +128,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name beforeAll * @name beforeAll
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to setup your specs. * @param {implementationCallback} [function] Function that contains the code to setup your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll.
*/ */
beforeAll: function() { beforeAll: function() {
@@ -132,7 +142,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
* @name afterAll * @name afterAll
* @function * @function
* @global * @global
* @param {Function} [function] Function that contains the code to teardown your specs. * @param {implementationCallback} [function] Function that contains the code to teardown your specs.
* @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll. * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll.
*/ */
afterAll: function() { afterAll: function() {