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