/** A class for spying on functions */
class Spy {
/** Constructs a new spy */
constructor() {
/**
* First constructor signature. Creates an anonymous function that records arguments, this value, exceptions and return values for all calls.
* @return {Function} A new empty spy
* @constructs Spy
*/
if (arguments.length === 0) {
// return a new spy
}
/**
* Second constructor signature. Spies on the provided function.
* @param {Function} myFunc The function to be spied on
* @returns {Function} The spy-wrapped function
* @constructs Spy
*/
if (arguments.length === 1 && typeof argument[0] === "function") {
// return a wrapped function
}
/**
* Third constructor signature. Creates a spy for object.method and replaces the original method with the spy.
* @param {Object} obj The object where 'method' resides
* @param {String} method The method to wrap in a spy
* @return {Object} The object that has the freshly wrapped method
* @constructs Spy
*/
if (arguments.length === 1 &&
typeof argument[0] === "object" &&
typeof argument[1] === "string") {
// return object with a freshly wrapped method
}
}
/** Checks whether the spy-wrapped function threw an error */
threw() {
/**
* First threw signature. Returns true if call threw an exception.
* @return {Boolean} True if spy-wrapped function threw an error, false otherwise
*/
if (arguments.length === 0) {
// do stuff...
}
/**
* Second threw signature. Returns true if call threw exception of provided type.
* @param {String} TypeError The type of error expected to be thrown
* @return {Boolean} True if spy-wrapped function threw an error of the type specified, false otherwise
*/
if (arguments.length === 1 && typeof arguments[0] === "string") {
// do stuff...
}
/**
* Second threw signature. Returns true if call threw provided exception object.
* @param {String} obj The type of error expected to be thrown
* @return {Boolean} True if spy-wrapped function threw an error of the object specified, false otherwise
*/
if (arguments.length === 1 && typeof arguments[0] === "object") {
// do stuff...
}
}
}
--
You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdoc-users+unsubscribe@googlegroups.com.
To post to this group, send email to jsdoc...@googlegroups.com.
Visit this group at https://groups.google.com/group/jsdoc-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsdoc-users/290d181e-6ac3-4daf-a56d-d459e04ebccb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.