Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.5.0 to 0.6.0

typings/jasmine/jasmine.d.ts

25

lib/mock-promises.js

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

if(isFunction(promise.isFulfilled)) {
//Q, mockedNative
//Q, mockedNative, bluebird
return promise.isFulfilled();

@@ -67,2 +67,3 @@ }

}
return false;
};

@@ -79,8 +80,9 @@

}
return false;
};
var MockPromise, OriginalPromise, originalThen, originalAll, originalRace;
var MockPromise, OriginalPromise, originalThen, originalAll, originalRace, contractsTracker;
var MockPromises = function() {
var contractsTracker = new ContractsTracker();
contractsTracker = new ContractsTracker();

@@ -267,2 +269,9 @@ this.install = function(ExternalPromiseClass) {

this.tick = function(count) {
if(!count) count = 1;
for(var i = 0; i < count; i++){
contractsTracker.executeForResolvedPromises();
}
};
this.contracts = contractsTracker;

@@ -280,5 +289,11 @@ };

function resolvePromise(promise, value) {
function resolvePromise(promise, value, fulfilledHandler, errorHandler, progressHandler) {
if(value && isFunction(value.then)) {
extend(promise, value);
if (isFulfilled(value) || isRejected(value)) {
extend(promise, value);
} else {
each(contractsTracker.forPromise(promise), function(contract) {
contractsTracker.add(extend(contract, {promise: value}));
});
}
} else {

@@ -285,0 +300,0 @@ extend(promise, {

2

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

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

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

##Supported Libraries
Mock Promises currently supports the [Q] promise library, [es6-promise] libary (but not the `all` function), and native Promises (only for simple uses) in Chrome. If you would like to use Mock Promises for a library that is not supported, please open a github issue.
Mock Promises currently supports [es6-promise], [bluebird], [Q] and native Promises (where available). If you would like to use Mock Promises for a library that is not supported, please open a github issue.

@@ -34,2 +34,3 @@ Mock Promises is test framework agnostic, and we have code examples for the [jasmine] and [mocha] testing frameworks in the [spec/javascripts] directory.

```
- Other Libraries

@@ -67,3 +68,3 @@

###Promise Resolution Policy
Promises often lead to other promises, for example, `promise.then(function1).then(function2)`, so we had to decide what happens to the `function2` on a promise when you execute the `function1`. We have chosen to force the user to explicitly ask for each callback to be executed, so that they do not accidentally execute callacks without realizing it. Even `executeForResolvedPromises` will only go down one level of the chain for each call. To manually go down a promise chain, you can use `iterateForPromise`.
Promises often lead to other promises, for example, `promise.then(function1).then(function2)`, so we had to decide what happens to the `function2` on a promise when you execute the `function1`. We have chosen to force the user to explicitly ask for each callback to be executed, so that they do not accidentally execute callacks without realizing it. Even `tick` will only go down one level of the chain unless the user specifies the number of levels. To manually go down a promise chain, you can use `iterateForPromise`.

@@ -87,2 +88,5 @@ ##API

###tick(count)
Executes all fulfillmentHandlers for each resolved promise. Executes all rejection handlers for each rejected promise. If passed a count, `tick` will repeat this procedure that many times. This is useful for deeply chained `then`s.
###executeForPromise(mockedPromise)

@@ -179,2 +183,3 @@ Executes all fulfillmentHandlers if the mocked promise is resolved. Executes all rejectionHandlers if the mocked promise is rejected. Will not execute handlers that have already been executed.

[es6-promise]:https://github.com/jakearchibald/es6-promise
[bluebird]:https://github.com/petkaantonov/bluebird
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