var events = require('eventemitter2'),
vows = require('vows'),
assert = require('../helpers/assert'),
broadway = require('../../lib/broadway');
vows.describe('broadway/app').addBatch({
"An initialized instance of broadway.App with three plugins": {
topic: function () {
var app = new broadway.App(),
that = this,
three;
that.init = [];
three = {
name: 'three',
init: function (cb) {
process.nextTick(function () {
that.init.push('three');
cb();
})
}
};
app.use({
attach: function () {
this.place = 'rackspace';
},
init: function (cb) {
var self = this;
process.nextTick(function () {
that.init.push('one');
self.letsGo = function () {
return 'Let\'s go to '+self.place+'!';
}
cb();
});
}
});
app.use({
attach: function () {
this.oneup = function (n) {
n++;
return n;
}
}
});
app.use(three);
app.use(three);
app.remove(three);
app.use(three);
app.remove({
name: 'foo'
});
app.init(function (err) {
that.callback(err, app);
});
},
"shouldn't throw an error": function (err, app) {
assert.ok(!err);
},
"should have all its methods attached/defined": function (err, app) {
assert.ok(app.place);
assert.isFunction(app.oneup);
assert.isFunction(app.letsGo);
assert.equal(2, app.oneup(1));
assert.equal(app.letsGo(), 'Let\'s go to rackspace!');
assert.deepEqual(this.init, ['one', 'three']);
},
}
}).export(module);