Created
April 10, 2012 17:10
-
-
Save tommedema/2352922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vows = require('vows'), | |
assert = require('assert'), | |
EventEmitter2 = require('eventemitter2').EventEmitter2, | |
bootutil = require(__dirname + '/../src/boot/util'); | |
vows.describe('Boot util').addBatch({ | |
'when loading some existing test routines without mediator': { | |
topic: function() { | |
bootutil.loadRoutines(__dirname + '/testroutines-nomediator', this.callback); | |
}, | |
'these are returned properly': function(err, routines) { | |
assert.isNull(err); | |
assert.isArray(routines); | |
assert.isTrue(routines.length > 0); | |
}, | |
'and are loaded properly': function(err, routines) { | |
assert.isTrue(global.TESTROUTINELOADED); | |
}, | |
'and are loaded recursively': function(err, routines) { | |
assert.isTrue(global.TESTROUTINELOADEDRECURSIVELY); | |
} | |
}, | |
'when loading existing test routines with mediator': { | |
topic: function() { | |
var mediator = new EventEmitter2({ | |
wildcard: false | |
}); | |
bootutil.loadRoutines(__dirname + '/testroutines', mediator, this.callback.bind(this, mediator)); | |
}, | |
'these are returned properly': function(mediator, err, routines) { | |
assert.isNull(err); | |
assert.isArray(routines); | |
assert.isTrue(routines.length > 0); | |
}, | |
'and are loaded properly': function(mediator, err, routines) { | |
assert.isTrue(global.TESTROUTINELOADED); | |
}, | |
'and are loaded recursively': function(mediator, err, routines) { | |
assert.isTrue(global.TESTROUTINELOADEDRECURSIVELY); | |
}, | |
'when emitting events': { | |
topic: function(mediator, err, routines) { | |
mediator.once('success', this.callback); | |
mediator.emit('boot'); | |
}, | |
'routines properly receive and respond to these': function(msg) { | |
assert.isTrue(msg === 'success'); | |
} | |
} | |
}, | |
'when loading nonexisting routine folder': { | |
topic: function() { | |
bootutil.loadRoutines(__dirname + '/testnonexistant', this.callback); | |
}, | |
'we get an error': function(err, routines) { | |
assert.isNotNull(err); | |
} | |
} | |
}).export(module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tommedema@tommedema-Aspire-7741:~/Desktop/Workspaces/Node.js/MusicTV$ vows ./test/*test.js --spec | |
♢ Boot util | |
when loading nonexisting routine folder | |
✓ we get an error | |
when loading some existing test routines without mediator | |
✓ these are returned properly | |
✓ and are loaded properly | |
✓ and are loaded recursively | |
when loading existing test routines with mediator | |
✓ these are returned properly | |
✓ and are loaded properly | |
✓ and are loaded recursively | |
✗ Errored » 7 honored ∙ 1 errored |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment