mock.js
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "mock.js", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Lightweight Mock Object Testing For Javascript.", | ||
@@ -19,2 +19,2 @@ "author": { | ||
} | ||
} | ||
} |
@@ -147,4 +147,21 @@ Mock.js Testing Utility | ||
NOTE: Unforuntanely using `consume` only works on synchronous ajax request for now. | ||
There are some cases where returning a predefined mock result isn't the best way to write your test. In these scenarios, you can use consumeWithFake() instead to pass an executable method into the spy. | ||
```javascript | ||
var spy = Mock.Spy(jQuery, "ajax"); | ||
spy.consumeWithFake(function (opts) { | ||
// do something with opts, then return a result | ||
}); | ||
jQuery.ajax({"url": "example.js"}); | ||
alert(spy.called()); | ||
alert(spy.returnedWith()); | ||
Calling consumeWithFake() means that the method's arguments will now be passed to the mocked method, and returnedWith() will be that method's return value. | ||
NOTE: Unfortunately using `consume/consumeWithFake` only works on synchronous ajax request for now. | ||
6. Releasing Mocks | ||
@@ -198,2 +215,2 @@ ------------------ | ||
* GNU General Public License | ||
* see http://www.gnu.org/licenses | ||
* see http://www.gnu.org/licenses |
58386
215