promise.js 1.2 KB

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