Bones/node_modules/es6-shim/test/promise/reject.js
SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

35 lines
1.2 KiB
JavaScript

var failIfThrows = function (done) {
'use strict';
return function (e) {
done(e || new Error());
};
};
describe('Promise.reject', function () {
'use strict';
it('should not be enumerable', function () {
expect(Promise).ownPropertyDescriptor('reject').to.have.property('enumerable', false);
});
it('should return a rejected promise', function (done) {
var value = {};
Promise.reject(value).then(failIfThrows(done), function (result) {
expect(result).to.equal(value);
done();
});
});
it('throws when receiver is a primitive', function () {
var promise = Promise.reject();
expect(function () { Promise.reject.call(undefined, promise); }).to['throw']();
expect(function () { Promise.reject.call(null, promise); }).to['throw']();
expect(function () { Promise.reject.call('', promise); }).to['throw']();
expect(function () { Promise.reject.call(42, promise); }).to['throw']();
expect(function () { Promise.reject.call(false, promise); }).to['throw']();
expect(function () { Promise.reject.call(true, promise); }).to['throw']();
promise.then(null, function () {}); // silence unhandled rejection errors in Chrome
});
});