Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50659 views
1
/*
2
* app-test.js: Tests for core App methods and configuration.
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var events = require('eventemitter2'),
10
vows = require('vows'),
11
assert = require('../helpers/assert'),
12
broadway = require('../../lib/broadway');
13
14
vows.describe('broadway/app').addBatch({
15
"An instance of broadway.App": {
16
topic: new broadway.App(),
17
"should have the correct properties and methods": function (app) {
18
//
19
// Instance
20
//
21
assert.isObject(app);
22
assert.instanceOf(app, events.EventEmitter2);
23
assert.instanceOf(app, broadway.App);
24
25
//
26
// Properties
27
//
28
assert.isObject(app.plugins);
29
assert.isObject(app.initializers);
30
assert.isFalse(!!app.initialized);
31
32
//
33
// Methods
34
//
35
assert.isFunction(app.init);
36
assert.isFunction(app.use);
37
assert.isFunction(app.remove);
38
assert.isFunction(app.inspect);
39
},
40
"the init() method": {
41
topic: function (app) {
42
this.app = app;
43
app.init(this.callback);
44
},
45
"should correctly setup the application state": function () {
46
assert.isTrue(this.app.initialized);
47
assert.isTrue(this.app.initializers['log']);
48
49
assert.plugins.has.config(this.app);
50
assert.plugins.has.log(this.app);
51
}
52
},
53
"the detach() method": {
54
topic: function (app) {
55
app.use({
56
name: "foo",
57
attach: function () {
58
this.attached = true;
59
},
60
detach: function () {
61
this.detached = true;
62
}
63
});
64
app.remove("foo");
65
return app;
66
},
67
"should correctly remove a plugin": function (app) {
68
assert.isTrue(app.detached);
69
assert.equal(undefined, app.plugins["foo"]);
70
}
71
}
72
}
73
}).export(module);
74
75