Sha256: 1327c04e99144258fe9bc5fd1fd3dd8c62fa5cf5eb426b2bfb7a348f5df12895

Contents?: true

Size: 1.38 KB

Versions: 62

Compression:

Stored size: 1.38 KB

Contents

// Import
var events = require('events');
var expect = require('chai').expect;
var joe = require('joe');
var domain = require('./');

// =====================================
// Tests

joe.describe('domain-browser', function(describe,it){
	it('should work on throws', function(done){
		var d = domain.create();
		d.on('error', function(err){
			expect(err && err.message).to.eql('a thrown error');
			done();
		});
		d.run(function(){
			throw new Error('a thrown error');
		});
	});

	it('should be able to add emitters', function(done){
		var d = domain.create();
		var emitter = new events.EventEmitter();

		d.add(emitter);
		d.on('error', function (err) {
			expect(err && err.message).to.eql('an emitted error');
			done();
		});

		emitter.emit('error', new Error('an emitted error'));
	});

	it('should be able to remove emitters', function (done){
		var emitter = new events.EventEmitter();
		var d = domain.create();

		d.add(emitter);
		var domainGotError = false;
		d.on('error', function (err) {
			domainGotError = true
		});

		emitter.on('error', function (err) {
			expect(err && err.message).to.eql('This error should not go to the domain')

			// Make sure nothing race condition-y is happening
			setTimeout(function () {
				expect(domainGotError).to.eql(false)
				done()
			}, 0)
		})

		d.remove(emitter);
		emitter.emit('error', new Error('This error should not go to the domain'));
	})
});

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.268 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.267 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.266 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.265 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.264 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.263 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.262 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.261 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.260 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.259 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.258 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.256 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.255 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.254 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.253 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.252 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.251 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.250 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.249 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.247 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js