Skip to content

Commit

Permalink
Merge pull request #31 from elwayman02/documentation
Browse files Browse the repository at this point in the history
Update JSdoc
  • Loading branch information
elwayman02 committed Jun 25, 2015
2 parents d25bcaf + 481267f commit f6f4d40
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,13 @@

### Master

### 1.0.3 (June 25, 2015)
* Improve error messaging
* Update docs to more accurate JSDoc-style

### 1.0.2 (June 11, 2015)
* [FEATURE] Expose cleanup methods to non-global testing frameworks

### 1.0.1 (May 15, 2015)
* [FEATURE] Allow mocking of methods on the function prototype

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "js.edgar",
"version": "1.0.2",
"version": "1.0.3",
"description": "Lightweight Spy/Mock Library for JavaScript",
"author": {
"name": "Jordan Hawker",
Expand Down
48 changes: 24 additions & 24 deletions src/edgar.js
Expand Up @@ -2,8 +2,9 @@
* Js.Edgar is a lightweight Spy/Mock library for testing JavaScript.
*
* @package Js.Edgar
* @version 1.0.2
* @version 1.0.3
* @author Jordan Hawker <hawker.jordan@gmail.com>
* www.JordanHawker.com
* @license MIT
*/
(function (root, factory) {
Expand All @@ -25,8 +26,8 @@
/**
* Adds the Spy to a hash so it is accessible later when needed
*
* @param {Spy} spy The Spy to be tracked
* @param {String} method The name of the method the Spy is watching
* @param {Spy} spy - The Spy to be tracked
* @param {string} method - The name of the method the Spy is watching
*/
addSpy: function (spy, method) {
var spies = this.spies[method];
Expand All @@ -41,8 +42,8 @@
/**
* Retrieves a Spy from the hash lookup
*
* @param {Object} obj The object being watched
* @param {String} method The name of the method being watched
* @param {object} obj - The object being watched
* @param {string} method - The name of the method being watched
* @returns {Spy} The Spy that corresponds to the given object/method
*/
getSpy: function (obj, method) {
Expand All @@ -63,17 +64,17 @@
/**
* External API to create a Spy
*
* @param {Object} obj The object to watch
* @param {String} method The name of the method to watch
* @param {*} [Value] A mock value to return or method to invoke
* @param {object} obj - The object to watch
* @param {string} method - The name of the method to watch
* @param {*} [value] - A mock value to return or method to invoke
* @returns {Spy} A Spy watching the given object/method
*/
createSpy: function (obj, method, value) {
var type = typeof obj;
var spy;

if (type === 'undefined') { // Create a callback
throw 'Mocking without objects is not yet supported';
throw 'Mocking without objects is not yet supported' + (typeof method === 'string' ? (': ' + method) : '');
// return this.createMock(obj);
} else if ((type === 'object' && obj !== null) || type === 'function') {
if (typeof method === 'string') { // Create a normal spy
Expand Down Expand Up @@ -149,17 +150,16 @@
});
}
};

/**
* Spy constructor
*
* @param {Object} obj The object to watch
* @param {String} method The name of the method to watch
* @param {*} [value] A mock value to return or method to invoke
* @constructor
*/
Edgar.Spy = (function () {

/**
* Spy constructor
*
* @param {Object} obj - The object to watch
* @param {String} method - The name of the method to watch
* @param {*} [value] - A mock value to return or method to invoke
* @constructor
*/
function Spy(obj, method, value) {
if (!(this instanceof Spy)) {
return new Spy(obj, method, value);
Expand Down Expand Up @@ -226,7 +226,7 @@
/**
* Setup the Spy to mock the method being watched
*
* @param {*} [value] The value to return/invoke for the mock
* @param {*} [value] - The value to return/invoke for the mock
* @returns {Spy} Itself
*/
self.andMock = self.startMocking = function (value) {
Expand All @@ -240,7 +240,7 @@
/**
* Find out how many calls have been made to the watched method
*
* @returns {Number} The number of calls made
* @returns {number} The number of calls made
*/
self.called = function () {
return self.calls.length;
Expand All @@ -250,8 +250,8 @@
* Get the arguments passed to the watched method,
* defaulting to the most recent call if no id is passed
*
* @param {Number} [id] The id of the call, in case of multiple
* @returns {Array} The arguments array for that call
* @param {number} [id] - The id of the call, in case of multiple
* @returns {array} The arguments array for that call
*/
self.calledWith = function (id) {
if (id !== undefined && id !== null) {
Expand All @@ -269,7 +269,7 @@
* Get the return value passed from Spy.mock(),
* defaulting to the most recent call if no id is passed
*
* @param {Number} [id] The id of the call, in case of multiple
* @param {number} [id] The id of the call, in case of multiple
* @returns {*} The return value for that call
*/
self.returnedWith = function (id) {
Expand All @@ -287,7 +287,7 @@
* Get the context of 'this' passed to Spy.mock(),
* defaulting to the spied object if 'this' was the Spy itself
*
* @param {Number} [id] The id of the call, in case of multiple
* @param {number} [id] The id of the call, in case of multiple
* @returns {*} The context of that call
*/
self.getContext = function (id) {
Expand Down

0 comments on commit f6f4d40

Please sign in to comment.