Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created May 5, 2012 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommedema/2603686 to your computer and use it in GitHub Desktop.
Save tommedema/2603686 to your computer and use it in GitHub Desktop.
require('should');
var EventEmitter2 = require('eventemitter2').EventEmitter2
bootutil = require('../src/boot/util');
describe('boot util', function() {
it('should load existing test routines without mediator', function() {
bootutil.loadRoutines(__dirname + '/testroutines-nomediator', function(err, routines) {
err.should.not.exist();
routines.should.be.an.instanceof(Array);
routines.should.have.lengthOf(2);
global.TESTROUTINELOADED.should.be.true;
global.TESTROUTINELOADEDRECURSIVELY.should.be.true;
});
}),
it('should load existing test routines with working mediator', function() {
var mediator = new EventEmitter2({
wildcard: false
}),
loadedone = false,
loadedtwo = false;
mediator.once('testroutineloaded', function() {
loadedone = true;
});
mediator.once('testsubroutineloaded', function() {
loadedtwo = true;
});
bootutil.loadRoutines(__dirname + '/testroutines', mediator, function(err, routines) {
err.should.not.exist();
routines.should.be.an.instanceof(Array);
routines.should.have.lengthOf(2);
global.TESTROUTINELOADED.should.be.true;
global.TESTROUTINELOADEDRECURSIVELY.should.be.true;
loadedone.should.be.true;
loadedtwo.should.be.true;
throw "HEY MOCHA I SHOULD MAKE YOU FAIL BUT YOU DONT. WHY NOT? MULTIPLE ASYNC CALLBACKS DUE TO MEDIATOR???"
});
})
/*
it('should return error on nonexisting folder', function() {
bootutil.loadRoutines(__dirname + '/idonotexist', function(err, routines) {
err.should.exist();
routines.should.not.exist();
});
})
*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment