Socket
Socket
Sign inDemoInstall

mock-promises

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-promises - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

34

lib/mock-promises.js

@@ -27,3 +27,3 @@ (function (root, factory) {

var MockPromise, OriginalPromise, originalThen, originalAll;
var MockPromise, OriginalPromise, originalThen, originalAll, originalRace;

@@ -54,2 +54,9 @@ var MockPromises = function() {

}
if(MockPromise.race) {
if (MockPromise.race !== fakeRace) {
originalRace = MockPromise.race;
}
MockPromise.race = fakeRace;
}

@@ -97,2 +104,4 @@ };

MockPromise.race = fakeRace;
MockPromise.prototype.inspect = function() {

@@ -175,2 +184,23 @@ return {value: self.resolvedValue, reason: self.rejectedValue};

var fakeRace = function(promises){
return new MockPromise(function(resolve, reject) {
var raceFinished = false;
promises.forEach(function(promise) {
promise.then(
function(val){
if (!raceFinished) {
raceFinished = true;
resolve(val)
}
}, function(val){
if (!raceFinished) {
raceFinished = true;
reject(val)
}
});
});
});
};
var self = this;

@@ -181,3 +211,3 @@ each([

self[methodName] = function() {
return contractsTracker[methodName].apply(contractsTracker, arguments)
return contractsTracker[methodName].apply(contractsTracker, arguments);
}

@@ -184,0 +214,0 @@ });

2

package.json
{
"name": "mock-promises",
"version": "0.3.0",
"version": "0.4.0",
"author": "Charles Hansen <chansen87@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -52,3 +52,3 @@ #Mock Promises

## Native Promises
If you are using Native promises, mock promises needs to mock out the constructor, which requires `getMockPromise`. This method is doing a lot more than `install`, and is still in development. Mock Promises currently has significantly reduced functionality with Native Promises.
If you are using Native promises, mock promises needs to mock out the constructor, which requires `getMockPromise`. This method is doing a lot more than `install` and may have slightly different behavior than mocking out promises from libraries.

@@ -55,0 +55,0 @@ ```js

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc