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 1.1.0 to 1.2.0

CHANGELOG.md

9

index.js

@@ -29,4 +29,3 @@ function buildThenable() {

if (this.rejected && onReject) {
onReject(this.rejectValue);
return this;
return this.catch(onReject);
}

@@ -39,3 +38,7 @@ return this;

try {
onReject(this.rejectValue);
const value = onReject(this.rejectValue);
this.resolved = true;
this.rejected = false;
this.resolveValue = value;
this.rejectValue = undefined;
} catch (e) {

@@ -42,0 +45,0 @@ this.rejectValue = e;

{
"name": "sinon-stub-promise",
"version": "1.1.0",
"version": "1.2.0",
"description": "Synchronous Promise stubbing for Sinon.JS",

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

var sinon = require('sinon');
var sinonStubPromise = require('../index');
var AssertionError = require('chai').AssertionError;
var expect = require('chai').expect;
var chai = require('chai');
var RSVP = require('rsvp');
var expect = chai.expect;
var assert = chai.assert;

@@ -32,7 +34,7 @@ sinonStubPromise(sinon);

});
it('can resolve multiple times with the same value', function() {
var secondResolvedValue = null;
promise.resolves('resolve value');
promise().then(function(arg) {

@@ -42,3 +44,3 @@ resolveValue = arg;

expect(resolveValue).to.equal('resolve value');
promise().then(function(arg) {

@@ -191,2 +193,28 @@ secondResolvedValue = arg;

it('handles catches that succeed', function(done) {
promise.rejects('an error');
promise().then(f, function(e) {
expect(e).to.equal('an error');
return 'no error';
}).then(function (d) {
expect(d).to.equal('no error');
done();
})
});
it('handles catches that fail', function(done) {
promise.rejects('an error');
promise().then(f, function(e) {
expect(e).to.equal('an error');
throw new Error('another');
}).then(function () {
done(new Error("Promise did not throw"))
}, function (e) {
expect(e.message).to.equal('another');
done();
})
});
describe('chaining', function() {

@@ -303,3 +331,20 @@ it('supports then chaining', function(done) {

});
it('does execute additional then blocks when an error has been caught', function(done) {
promise.resolves();
promise()
.then(function() {
throw new Error('Stop the insanity');
})
.catch(function(error) {
expect(error.message).to.eql('Stop the insanity');
return 'No more error';
})
.then(function (r) {
expect(r).to.eql('No more error');
done();
});
});
});
});
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