promise.domain.test.js 644 B

12345678910111213141516171819202122232425262728
  1. var Promise = require('../')
  2. , Domain = require('domain').Domain
  3. , assert = require('assert');
  4. describe("domains", function () {
  5. it("exceptions should not breakout of domain boundaries", function (done) {
  6. if (process.version.indexOf('v0.10') != 0) return done();
  7. var d = new Domain;
  8. d.on('error', function (err) {
  9. assert.equal(err.message, 'gaga');
  10. done()
  11. });
  12. var p = new Promise();
  13. d.run(function () {
  14. p.then(
  15. function () {}
  16. ).then(
  17. function () { throw new Error('gaga'); }
  18. ).end();
  19. });
  20. process.nextTick(function () {
  21. p.fulfill();
  22. });
  23. });
  24. });