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

sinon-stub-promise

Package Overview
Dependencies
Maintainers
5
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinon-stub-promise - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## [v3.0.0]
> July 16, 2016
- **Major:** Only invoke onResolve/onReject when stub.resolve()/stub.reject()
called ([#18](https://github.com/substantial/sinon-stub-promise/pull/18))
## [v2.0.0]

@@ -2,0 +8,0 @@ > April 13, 2016

function buildThenable() {
return {
onFulfilled: [],
onRejected: [],
onFinally: [],
then: function(onFulfill, onReject) {

@@ -31,2 +34,8 @@ try {

}
if (!this.rejected && onFulfill) {
this.onFulfilled.push(onFulfill);
}
if (!this.resolved && onReject) {
this.onRejected.push(onReject);
}
return this;

@@ -48,2 +57,5 @@ },

}
if (!this.resolved) {
this.onRejected.push(onReject);
}
return this;

@@ -55,3 +67,5 @@ },

callback();
return;
}
this.onFinally.push(callback);
}

@@ -66,2 +80,7 @@ };

this.thenable.resolveValue = value;
this.thenable.onFulfilled
.concat(this.thenable.onFinally)
.forEach(function(callback) {
callback(value);
});
return this;

@@ -74,2 +93,7 @@ }

this.thenable.rejectValue = value;
this.thenable.onRejected
.concat(this.thenable.onFinally)
.forEach(function(callback) {
callback(value);
});
return this;

@@ -76,0 +100,0 @@ }

2

package.json
{
"name": "sinon-stub-promise",
"version": "2.1.0",
"version": "3.0.0",
"description": "Synchronous Promise stubbing for Sinon.JS",

@@ -5,0 +5,0 @@ "author": "Alex May <alex@substantial.com>",

@@ -70,3 +70,14 @@ var sinon = require('sinon');

});
it('does resolve synchronously when explicitly resolved AFTER a then is added', function() {
var resolved = false;
promise().then(function() {
resolved = true;
});
expect(resolved).to.be.false;
promise.resolves();
expect(resolved).to.be.true;
});
it('returns stub from resolves call', function(done) {

@@ -124,3 +135,25 @@ var stub = promise.resolves();

});
it('can reject via catch synchronously when explicitly rejected AFTER a catch is added', function() {
var rejected = false;
promise().catch(function() {
rejected = true;
});
expect(rejected).to.be.false;
promise.rejects();
expect(rejected).to.be.true;
});
it('can reject via a then reject function synchronously when explicitly rejected AFTER a then reject function is added', function() {
var rejected = false;
promise().then(f, function() {
rejected = true;
});
expect(rejected).to.be.false;
promise.rejects();
expect(rejected).to.be.true;
});
it('returns stub from rejects call', function(done) {

@@ -182,2 +215,13 @@ var stub = promise.rejects();

it('invokes finally when promise is resolved after the finally is added', function() {
var finallyCalled = false;
promise().finally(function() {
finallyCalled = true;
});
expect(finallyCalled).to.be.false;
promise.resolves();
expect(finallyCalled).to.be.true;
});
it('invokes finally when promise is rejected', function() {

@@ -194,2 +238,13 @@ promise.rejects();

it('invokes finally when promise is rejected after the finally is added', function() {
var finallyCalled = false;
promise().finally(function() {
finallyCalled = true;
});
expect(finallyCalled).to.be.false;
promise.rejects();
expect(finallyCalled).to.be.true;
});
it('handles catches that succeed', function(done) {

@@ -196,0 +251,0 @@ promise.rejects('an error');

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