promises-aplus-tests
Advanced tools
Comparing version 1.3.2 to 2.0.0
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97412
21
2230
1
+ Addeddiff@1.0.7(transitive)
+ Addedglob@3.2.3(transitive)
+ Addedgraceful-fs@2.0.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedmocha@1.13.0(transitive)
+ Addedunderscore@1.5.2(transitive)
- Removeddiff@1.0.2(transitive)
- Removedglob@3.2.1(transitive)
- Removedgraceful-fs@1.2.3(transitive)
- Removedinherits@1.0.2(transitive)
- Removedmocha@1.11.0(transitive)
- Removedms@0.3.0(transitive)
- Removedunderscore@1.4.4(transitive)
Updatedmocha@~1.13.0
Updatedunderscore@~1.5.2