Debian Codegraph @

test/promise/resolve.js

raw
1 var failIfThrows = function (done) {
2 'use strict';
3
4 return function (e) {
5 done(e || new Error());
6 };
7 };
8
9 describe('Promise.resolve', function () {
10 'use strict';
11
12 it('should not be enumerable', function () {
13 expect(Promise).ownPropertyDescriptor('resolve').to.have.property('enumerable', false);
14 });
15
16 it('should return a resolved promise', function (done) {
17 var value = {};
18 Promise.resolve(value).then(function (result) {
19 expect(result).to.equal(value);
20 done();
21 }, failIfThrows(done));
22 });
23
24 it('throws when receiver is a primitive', function () {
25 var promise = Promise.resolve();
26 expect(function () { Promise.resolve.call(undefined, promise); }).to['throw']();
27 expect(function () { Promise.resolve.call(null, promise); }).to['throw']();
28 expect(function () { Promise.resolve.call('', promise); }).to['throw']();
29 expect(function () { Promise.resolve.call(42, promise); }).to['throw']();
30 expect(function () { Promise.resolve.call(false, promise); }).to['throw']();
31 expect(function () { Promise.resolve.call(true, promise); }).to['throw']();
32 });
33 });