UNPKG

1.26 kBJavaScriptView Raw
1/* This file is for testing implementation regressions of Promises. */
2
3describe('Promise', function () {
4 if (typeof Promise === 'undefined') {
5 return it('exists', function () {
6 expect(typeof Promise).to.be('function');
7 });
8 }
9
10 var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
11
12 ifShimIt('is on the exported object', function () {
13 var exported = require('../');
14 expect(exported.Promise).to.equal(Promise);
15 });
16
17 it('ignores non-function .then arguments', function () {
18 expect(function () {
19 Promise.reject(42).then(null, 5).then(null, function () {});
20 }).not.to['throw']();
21 });
22
23 describe('extra methods (bad Chrome!)', function () {
24 it('does not have accept', function () {
25 expect(Promise).not.to.have.property('accept');
26 });
27
28 it('does not have defer', function () {
29 expect(Promise).not.to.have.property('defer');
30 });
31
32 it('does not have chain', function () {
33 expect(Promise.prototype).not.to.have.property('chain');
34 });
35 });
36
37 it('requires an object context', function () {
38 // this fails in Safari 7.1 - 9
39 expect(function promiseDotCallThree() {
40 Promise.call(3, function () {});
41 }).to['throw']();
42 });
43});