Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/tests/2.2.7.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

var expect = require("chai").expect;
var assert = require("assert");
var testFulfilled = require("./helpers/testThreeCases").testFulfilled;
var testRejected = require("./helpers/testThreeCases").testRejected;
Expand Down Expand Up @@ -58,6 +59,26 @@ describe("2.2.7: `then` must return a promise: `promise2 = promise1.then(onFulfi
testReason(reasons[stringRepresentation](), stringRepresentation);
});
});

describe("2.2.7.2.2: If either `onFulfilled` or `onRejected` throws an exception `e`, and no next `then` to " +
"handle rejection and no `catch`, should throw a global exception `e`", function () {
specify("throw directly", function (done) {
class customError extends Error {
constructor() {
super();
this.name = 'customError';
}
}
process.once('unhandledRejection', (reason) => {
expect(reason).to.be.an.instanceOf(customError);
done()
});

adapter.resolved(1).then((res)=>{
throw new customError();
})
});
})

describe("2.2.7.3: If `onFulfilled` is not a function and `promise1` is fulfilled, `promise2` must be fulfilled " +
"with the same value.", function () {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"prepublish": "node ./scripts/generateTestFiles.js"
},
"dependencies": {
"chai": "^4.0.1",
"mocha": "^2.5.3",
"sinon": "^1.10.3",
"underscore": "~1.8.3"
Expand Down