Socket
Socket
Sign inDemoInstall

mock.js

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

4

package.json
{
"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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc