35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
var assert = require("assert");
|
||
|
|
||
|
var adapter = global.adapter;
|
||
|
var fulfilled = adapter.fulfilled;
|
||
|
var rejected = adapter.rejected;
|
||
|
|
||
|
var dummy = { dummy: "dummy" }; // we fulfill or reject with this when we don't intend to test against it
|
||
|
|
||
|
describe("2.3.1: If `promise` and `x` refer to the same object, reject `promise` with a `TypeError' as the reason.",
|
||
|
function () {
|
||
|
specify("via return from a fulfilled promise", function (done) {
|
||
|
var promise = fulfilled(dummy).then(function () {
|
||
|
return promise;
|
||
|
});
|
||
|
|
||
|
promise.then(null, function (reason) {
|
||
|
assert(reason instanceof adapter.TypeError);
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
specify("via return from a rejected promise", function (done) {
|
||
|
var promise = rejected(dummy).then(null, function () {
|
||
|
return promise;
|
||
|
});
|
||
|
|
||
|
promise.then(null, function (reason) {
|
||
|
assert(reason instanceof adapter.TypeError);
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
});
|