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.228 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.227 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.226 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.225 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.224 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.9 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.223 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.222 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.221 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.220 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.219 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.218 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.217 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.216 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.215 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.214 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.213 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.212 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.211 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js
smock-0.1.210 node_modules/webpack/node_modules/node-libs-browser/node_modules/domain-browser/test.js