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

34 lines
1.1 KiB
JavaScript

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