Socket
Socket
Sign inDemoInstall

chai-as-promised

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 3.0.0

test/browser/libraries/jquery.coffee

78

lib/chai-as-promised.js

@@ -15,7 +15,6 @@ (function (chaiAsPromised) {

} else {
// Other environment (usually <script> tag): attach to global.
var global = (false || eval)("this");
global.chaiAsPromised = chaiAsPromised;
// Other environment (usually <script> tag): plug in to global chai instance directly.
chai.use(chaiAsPromised);
}
}(function chaiAsPromised(chai) {
}(function chaiAsPromised(chai, utils) {
"use strict";

@@ -48,9 +47,9 @@

var fulfilledAsserter = function () {
var transformedPromise = this.obj.then(
var transformedPromise = this._obj.then(
function (value) {
if (this.negate) {
if (utils.flag(this, "negate")) {
// If we're negated, `this.assert`'s behavior is actually flipped, so `this.assert(true, ...)` will
// throw an error, as desired.
this.assert(true, null, "expected " + this.inspect + " to be rejected but it was fulfilled with " +
chai.inspect(value));
this.assert(true, null, "expected promise to be rejected but it was fulfilled with " +
utils.inspect(value));
}

@@ -63,4 +62,4 @@

// pass, as desired.
this.assert(false, "expected " + this.inspect + " to be fulfilled but it was rejected with " +
chai.inspect(reason));
this.assert(false, "expected promise to be fulfilled but it was rejected with " +
utils.inspect(reason));
}.bind(this)

@@ -99,4 +98,3 @@ );

var onOriginalFulfilled = function (value) {
this.assert(false, "expected " + this.inspect + " to be rejected but it was fulfilled with " +
chai.inspect(value));
this.assert(false, "expected promise to be rejected but it was fulfilled with " + utils.inspect(value));
}.bind(this);

@@ -109,5 +107,5 @@

if (this.negate) {
this.assert(true, null, "expected " + this.inspect + " to be fulfilled but it was rejected with " +
chai.inspect(reason));
if (utils.flag(this, "negate")) {
this.assert(true, null, "expected promise to be fulfilled but it was rejected with " +
utils.inspect(reason));
}

@@ -155,8 +153,8 @@

var onTransformedFulfilled = function () {
if (!this.negate) {
if (!utils.flag(this, "negate")) {
if (desiredReason) {
this.assert(matchesDesiredReason(),
null,
"expected " + this.inspect + " to be rejected with " + chai.inspect(desiredReason) +
"but it was rejected with " + chai.inspect(rejectionReason));
"expected promise to be rejected with " + utils.inspect(desiredReason) + " but " +
"it was rejected with " + utils.inspect(rejectionReason));
}

@@ -166,4 +164,4 @@

this.assert(constructorIsGood(),
"expected " + this.inspect + " to be rejected with " + Constructor.prototype.name +
" but it was rejected with " + chai.inspect(rejectionReason));
"expected promise to be rejected with " + Constructor.prototype.name + " but it " +
"was rejected with " + utils.inspect(rejectionReason));
}

@@ -173,4 +171,4 @@

this.assert(messageIsGood(),
"expected " + this.inspect + " to be rejected with an error " + messageVerb + " " +
message + " but got " + chai.inspect(rejectionReason.message));
"expected promise to be rejected with an error " + messageVerb + " " + message +
" but got " + utils.inspect(rejectionReason.message));
}

@@ -181,8 +179,7 @@ }

var onTransformedRejected = function () {
if (this.negate) {
if (utils.flag(this, "negate")) {
if (desiredReason) {
this.assert(matchesDesiredReason(),
null,
"expected " + this.inspect + " to not be rejected with " +
chai.inspect(desiredReason));
"expected promise to not be rejected with " + utils.inspect(desiredReason));
}

@@ -193,4 +190,3 @@

null,
"expected " + this.inspect + " to not be rejected with " +
Constructor.prototype.name);
"expected promise to not be rejected with " + Constructor.prototype.name);
}

@@ -201,4 +197,4 @@

null,
"expected " + this.inspect + " to be not be rejected with an error " + messageVerb +
" " + message);
"expected promise to be not be rejected with an error " + messageVerb + " " +
message);
}

@@ -208,14 +204,14 @@ } else {

this.assert(false,
"expected " + this.inspect + " to be rejected with " + chai.inspect(desiredReason) +
"but it was fulfilled");
"expected promise to be rejected with " + utils.inspect(desiredReason) +
" but it was fulfilled");
}
if (Constructor) {
this.assert(false, "expected " + this.inspect + " to be rejected with " +
Constructor.prototype.name + " but it was fulfilled");
this.assert(false, "expected promise to be rejected with " + Constructor.prototype.name +
" but it was fulfilled");
}
if (message) {
this.assert(false, "expected " + this.inspect + " to be rejected with an error " + messageVerb +
" " + message + " but it was fulfilled");
this.assert(false, "expected promise to be rejected with an error " + messageVerb + " " +
message + " but it was fulfilled");
}

@@ -228,3 +224,3 @@ }

var transformedPromise = promiseWithAsserters(this.obj.then(onOriginalFulfilled, onOriginalRejected), this);
var transformedPromise = promiseWithAsserters(this._obj.then(onOriginalFulfilled, onOriginalRejected), this);
Object.defineProperty(transformedPromise, "with", { enumerable: true, configurable: true, value: withMethod });

@@ -240,7 +236,7 @@

if (fulfillmentValue instanceof Assertion) {
newAssertion = new Assertion(fulfillmentValue.obj);
newAssertion.negate = fulfillmentValue.negate;
newAssertion = new Assertion(fulfillmentValue._obj);
utils.flag(newAssertion, "negate", utils.flag(fulfillmentValue, "negate"));
} else {
newAssertion = new Assertion(fulfillmentValue);
newAssertion.negate = originalAssertion.negate;
utils.flag(newAssertion, "negate", utils.flag(originalAssertion, "negate"));
}

@@ -303,3 +299,3 @@

property("eventually", function () {
return promiseWithAsserters(this.obj, this);
return promiseWithAsserters(this._obj, this);
});

@@ -312,3 +308,3 @@

method("notify", function (callback) {
return notify(this.obj, callback);
return notify(this._obj, callback);
});

@@ -315,0 +311,0 @@

@@ -9,3 +9,3 @@ {

],
"version": "2.2.0",
"version": "3.0.0",
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",

@@ -24,2 +24,5 @@ "repository": {

"scripts": {
"test-browser-q": "coffee ./test/browser/runner q",
"test-browser-jquery": "coffee ./test/browser/runner jquery",
"test-browser-when": "coffee ./test/browser/runner when",
"test": "mocha",

@@ -36,7 +39,10 @@ "lint": "jshint ./lib --show-non-errors",

"mocha": "1",
"chai": "*",
"chai": "1",
"cover": "*",
"jshint": "*",
"q": "*"
"q": "*",
"glob": "*",
"ecstatic": "*",
"underscore": "*"
}
}

@@ -206,7 +206,8 @@ Chai Assertions for Working with Promises

If you include Chai as Promised directly with a `<script>` tag, it creates a `window.chaiAsPromised` global (again,
just like Chai). Then your setup code becomes:
If you include Chai as Promised directly with a `<script>` tag, after the one for Chai itself, then it will
automatically plug in to Chai and be ready for use:
```javascript
window.chai.use(window.chaiAsPromised);
```html
<script src="chai.js"></script>
<script src="chai-as-promised.js"></script>
```

@@ -213,0 +214,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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