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

promises-aplus-tests

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promises-aplus-tests - npm Package Compare versions

Comparing version 1.3.2 to 2.0.0

lib/tests/2.1.2.js

18

lib/programmaticRunner.js

@@ -11,7 +11,7 @@ "use strict";

function normalizeAdapter(adapter) {
if (!adapter.fulfilled) {
adapter.fulfilled = function (value) {
var tuple = adapter.pending();
tuple.fulfill(value);
return tuple.promise;
if (!adapter.resolved) {
adapter.resolved = function (value) {
var d = adapter.deferred();
d.resolve(value);
return d.promise;
};

@@ -22,5 +22,5 @@ }

adapter.rejected = function (reason) {
var tuple = adapter.pending();
tuple.reject(reason);
return tuple.promise;
var d = adapter.deferred();
d.reject(reason);
return d.promise;
};

@@ -40,3 +40,3 @@ }

normalizeAdapter(adapter);
mochaOpts = _.defaults(mochaOpts, { reporter: "spec", timeout: 200, slow: Infinity });
mochaOpts = _.defaults(mochaOpts, { timeout: 200, slow: Infinity });

@@ -43,0 +43,0 @@ fs.readdir(testsDir, function (err, testFileNames) {

"use strict";
var adapter = global.adapter;
var fulfilled = adapter.fulfilled;
var resolved = adapter.resolved;
var rejected = adapter.rejected;
var pending = adapter.pending;
var deferred = adapter.deferred;
exports.testFulfilled = function (value, test) {
specify("already-fulfilled", function (done) {
test(fulfilled(value), done);
test(resolved(value), done);
});
specify("immediately-fulfilled", function (done) {
var tuple = pending();
test(tuple.promise, done);
tuple.fulfill(value);
var d = deferred();
test(d.promise, done);
d.resolve(value);
});
specify("eventually-fulfilled", function (done) {
var tuple = pending();
test(tuple.promise, done);
var d = deferred();
test(d.promise, done);
setTimeout(function () {
tuple.fulfill(value);
d.resolve(value);
}, 50);

@@ -34,14 +34,14 @@ });

specify("immediately-rejected", function (done) {
var tuple = pending();
test(tuple.promise, done);
tuple.reject(reason);
var d = deferred();
test(d.promise, done);
d.reject(reason);
});
specify("eventually-rejected", function (done) {
var tuple = pending();
test(tuple.promise, done);
var d = deferred();
test(d.promise, done);
setTimeout(function () {
tuple.reject(reason);
d.reject(reason);
}, 50);
});
};

@@ -5,4 +5,4 @@ {

"keywords": ["promises", "promises-aplus"],
"version": "1.3.2",
"implements": ["Promises/A+ 1.0.0"],
"version": "2.0.0",
"implements": ["Promises/A+ 1.1.0"],
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",

@@ -23,9 +23,9 @@ "license": "WTFPL",

"dependencies": {
"mocha": "~1.11.0",
"mocha": "~1.13.0",
"sinon": "~1.7.3",
"underscore": "~1.4.4"
"underscore": "~1.5.2"
},
"devDependencies": {
"jshint": "~2.1.3"
"jshint": "~2.1.11"
}
}

@@ -21,19 +21,19 @@ <a href="http://promises-aplus.github.com/promises-spec">

- `fulfilled(value)`: creates a promise that is already fulfilled with `value`.
- `resolved(value)`: creates a promise that is resolved with `value`.
- `rejected(reason)`: creates a promise that is already rejected with `reason`.
- `pending()`: creates an object consisting of `{ promise, fulfill, reject }`:
- `deferred()`: creates an object consisting of `{ promise, resolve, reject }`:
- `promise` is a promise that is currently in the pending state.
- `fulfill(value)` moves the promise from the pending state to a fulfilled state, with fulfillment value `value`.
- `resolve(value)` resolves the promise with `value`.
- `reject(reason)` moves the promise from the pending state to the rejected state, with rejection reason `reason`.
The `fulfilled` and `rejected` exports are actually optional, and will be automatically created by the test runner using
`pending` if they are not present. But, if your promise library has the capability to create already-fulfilled or
The `resolved` and `rejected` exports are actually optional, and will be automatically created by the test runner using
`deferred` if they are not present. But, if your promise library has the capability to create already-resolved or
already-rejected promises, then you should include these exports, so that the test runner can provide you with better
code coverage and uncover any bugs in those methods.
Note that the tests will never pass a promise or a thenable as a fulfillment value. This allows promise implementations
that only have "resolve" functionality, and don't allow direct fulfillment, to implement the `pending().fulfill` and
`fulfilled`, since fulfill and resolve are equivalent when not given a thenable.
Note that the tests will never pass a promise or a thenable as a resolution. That means that we never use the promise-
or thenable-accepting forms of the resolve operation directly, and instead only use the direct fulfillment operation,
since fulfill and resolve are equivalent when not given a thenable.
Finally, note that none of these functions, including `pending().fulfill` and `pending().reject`, should throw
Finally, note that none of these functions, including `deferred().resolve` and `deferred().reject`, should throw
exceptions. The tests are not structured to deal with that, and if your implementation has the potential to throw

@@ -61,3 +61,3 @@ exceptions—e.g., perhaps it throws when trying to resolve an already-resolved promise—you should wrap direct calls to

The CLI takes as its first argument the filename of your adapter file, relative to the current working directory. It
tries to pass through any subsequent options to Mocha, so you can use e.g. `--reporter dot` or `--grep 3.2.6.4`.
tries to pass through any subsequent options to Mocha, so you can use e.g. `--reporter spec` or `--grep 2.2.4`.

@@ -64,0 +64,0 @@ ### Programmatically

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