mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 03:02:49 +00:00
updated package.json
This commit is contained in:
60
node_modules/broadway/test/common/directories-test.js
generated
vendored
Normal file
60
node_modules/broadway/test/common/directories-test.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* directories-test.js: Tests for working with directories in broadway.
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
vows = require('vows'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
var fixturesDir = path.join(__dirname, '..', 'fixtures'),
|
||||
emptyAppDir = path.join(fixturesDir, 'empty-app'),
|
||||
emptyAppFile = path.join(fixturesDir, 'sample-app.json'),
|
||||
appConfig = JSON.parse(fs.readFileSync(emptyAppFile, 'utf8')),
|
||||
directories = appConfig.directories;
|
||||
|
||||
vows.describe('broadway/common/directories').addBatch({
|
||||
"When using broadway.common.directories": {
|
||||
"it should have the correct methods defined": function () {
|
||||
assert.isObject(broadway.common.directories);
|
||||
assert.isFunction(broadway.common.directories.create);
|
||||
assert.isFunction(broadway.common.directories.remove);
|
||||
},
|
||||
"the normalize() method should correctly modify a set of directories": function () {
|
||||
directories = broadway.common.directories.normalize({'#ROOT': emptyAppDir}, directories);
|
||||
|
||||
Object.keys(directories).forEach(function (key) {
|
||||
assert.isTrue(directories[key].indexOf(emptyAppDir) !== -1);
|
||||
});
|
||||
},
|
||||
"the create() method": {
|
||||
topic: function () {
|
||||
broadway.common.directories.create(directories, this.callback);
|
||||
},
|
||||
"should create the specified directories": function (err, dirs) {
|
||||
assert.isTrue(!err);
|
||||
|
||||
dirs.forEach(function (dir) {
|
||||
assert.isTrue((fs.existsSync || path.existsSync)(dir));
|
||||
});
|
||||
},
|
||||
"the destroy() method": {
|
||||
topic: function () {
|
||||
broadway.common.directories.remove(directories, this.callback);
|
||||
},
|
||||
"should remove the specified directories": function (err, dirs) {
|
||||
assert.isTrue(!err);
|
||||
|
||||
dirs.forEach(function (dir) {
|
||||
assert.isFalse((fs.existsSync || path.existsSync)(dir));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
100
node_modules/broadway/test/core/app-init-test.js
generated
vendored
Normal file
100
node_modules/broadway/test/core/app-init-test.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* app-test.js: Tests for core App methods and configuration.
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
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();
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// First plugin. Includes an init step.
|
||||
app.use({
|
||||
attach: function () {
|
||||
this.place = 'rackspace';
|
||||
},
|
||||
|
||||
init: function (cb) {
|
||||
var self = this;
|
||||
|
||||
// a nextTick isn't technically necessary, but it does make this
|
||||
// purely async.
|
||||
process.nextTick(function () {
|
||||
that.init.push('one');
|
||||
self.letsGo = function () {
|
||||
return 'Let\'s go to '+self.place+'!';
|
||||
}
|
||||
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Second plugin. Only involves an "attach".
|
||||
app.use({
|
||||
attach: function () {
|
||||
this.oneup = function (n) {
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Third pluging. Only involves an "init".
|
||||
app.use(three);
|
||||
|
||||
// Attempt to use it again. This should not invoke `init()` twice
|
||||
app.use(three);
|
||||
|
||||
// Remove the plugin and use it again. This should not invoke `init()` twice
|
||||
app.remove(three);
|
||||
app.use(three);
|
||||
|
||||
// Removing a plugin which was never added should not affect the initlist
|
||||
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!');
|
||||
|
||||
//
|
||||
// This is intentional. The second plugin does not invoke `init`.
|
||||
//
|
||||
assert.deepEqual(this.init, ['one', 'three']);
|
||||
},
|
||||
}
|
||||
}).export(module);
|
||||
73
node_modules/broadway/test/core/app-test.js
generated
vendored
Normal file
73
node_modules/broadway/test/core/app-test.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* app-test.js: Tests for core App methods and configuration.
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var events = require('eventemitter2'),
|
||||
vows = require('vows'),
|
||||
assert = require('../helpers/assert'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
vows.describe('broadway/app').addBatch({
|
||||
"An instance of broadway.App": {
|
||||
topic: new broadway.App(),
|
||||
"should have the correct properties and methods": function (app) {
|
||||
//
|
||||
// Instance
|
||||
//
|
||||
assert.isObject(app);
|
||||
assert.instanceOf(app, events.EventEmitter2);
|
||||
assert.instanceOf(app, broadway.App);
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
assert.isObject(app.plugins);
|
||||
assert.isObject(app.initializers);
|
||||
assert.isFalse(!!app.initialized);
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
assert.isFunction(app.init);
|
||||
assert.isFunction(app.use);
|
||||
assert.isFunction(app.remove);
|
||||
assert.isFunction(app.inspect);
|
||||
},
|
||||
"the init() method": {
|
||||
topic: function (app) {
|
||||
this.app = app;
|
||||
app.init(this.callback);
|
||||
},
|
||||
"should correctly setup the application state": function () {
|
||||
assert.isTrue(this.app.initialized);
|
||||
assert.isTrue(this.app.initializers['log']);
|
||||
|
||||
assert.plugins.has.config(this.app);
|
||||
assert.plugins.has.log(this.app);
|
||||
}
|
||||
},
|
||||
"the detach() method": {
|
||||
topic: function (app) {
|
||||
app.use({
|
||||
name: "foo",
|
||||
attach: function () {
|
||||
this.attached = true;
|
||||
},
|
||||
detach: function () {
|
||||
this.detached = true;
|
||||
}
|
||||
});
|
||||
app.remove("foo");
|
||||
return app;
|
||||
},
|
||||
"should correctly remove a plugin": function (app) {
|
||||
assert.isTrue(app.detached);
|
||||
assert.equal(undefined, app.plugins["foo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
26
node_modules/broadway/test/core/broadway-test.js
generated
vendored
Normal file
26
node_modules/broadway/test/core/broadway-test.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* broadway-test.js: Tests for core App methods and configuration.
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
events = require('eventemitter2'),
|
||||
vows = require('vows'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
vows.describe('broadway').addBatch({
|
||||
"The broadway module": {
|
||||
"should have the appropriate properties and methods defined": function () {
|
||||
assert.isFunction(broadway.App);
|
||||
assert.isObject(broadway.common);
|
||||
assert.isObject(broadway.features);
|
||||
assert.isObject(broadway.plugins);
|
||||
assert.isObject(broadway.plugins.log);
|
||||
assert.isObject(broadway.plugins.config);
|
||||
assert.isObject(broadway.plugins.exceptions);
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
0
node_modules/broadway/test/fixtures/.gitkeep
generated
vendored
Normal file
0
node_modules/broadway/test/fixtures/.gitkeep
generated
vendored
Normal file
0
node_modules/broadway/test/fixtures/empty-app/.gitkeep
generated
vendored
Normal file
0
node_modules/broadway/test/fixtures/empty-app/.gitkeep
generated
vendored
Normal file
8
node_modules/broadway/test/fixtures/sample-app.json
generated
vendored
Normal file
8
node_modules/broadway/test/fixtures/sample-app.json
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"directories": {
|
||||
"app": "#ROOT/app",
|
||||
"config": "#ROOT/config",
|
||||
"lib": "#ROOT/lib",
|
||||
"test": "#ROOT/test"
|
||||
}
|
||||
}
|
||||
2
node_modules/broadway/test/fixtures/sample-app/app/index.js
generated
vendored
Normal file
2
node_modules/broadway/test/fixtures/sample-app/app/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
var broadway = require("../../../")
|
||||
5
node_modules/broadway/test/fixtures/sample-app/config/topics.json
generated
vendored
Normal file
5
node_modules/broadway/test/fixtures/sample-app/config/topics.json
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"topics": [
|
||||
|
||||
]
|
||||
}
|
||||
107
node_modules/broadway/test/helpers/assert.js
generated
vendored
Normal file
107
node_modules/broadway/test/helpers/assert.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* assert.js: Assertion helpers for broadway tests
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = module.exports = require('assert'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
nconf = require('nconf'),
|
||||
vows = require('vows');
|
||||
|
||||
//
|
||||
// ### Assertion helpers for working with `broadway.App` objects.
|
||||
//
|
||||
assert.app = {};
|
||||
|
||||
//
|
||||
// ### Assertion helpers for working with `broadway.plugins`.
|
||||
//
|
||||
assert.plugins = {};
|
||||
|
||||
//
|
||||
// ### Assert that an application has various plugins.
|
||||
//
|
||||
assert.plugins.has = {
|
||||
config: function (app, config) {
|
||||
assert.instanceOf(app.config, nconf.Provider);
|
||||
if (config) {
|
||||
//
|
||||
// TODO: Assert that all configuration has been loaded
|
||||
//
|
||||
}
|
||||
},
|
||||
exceptions: function (app) {
|
||||
|
||||
},
|
||||
directories: function (app) {
|
||||
if (app.options['directories']) {
|
||||
Object.keys(app.options['directories']).forEach(function (key) {
|
||||
assert.isTrue((fs.existsSync || path.existsSync)(app.options['directories'][key]));
|
||||
});
|
||||
}
|
||||
},
|
||||
log: function (app) {
|
||||
assert.isObject(app.log);
|
||||
|
||||
//
|
||||
// TODO: Assert winston.extend methods
|
||||
//
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// ### Assert that an application doesn't have various plugins
|
||||
//
|
||||
assert.plugins.notHas = {
|
||||
config: function (app) {
|
||||
assert.isTrue(!app.config);
|
||||
},
|
||||
exceptions: function (app) {
|
||||
|
||||
},
|
||||
directories: function (app) {
|
||||
assert.isTrue(!app.config.get('directories'))
|
||||
},
|
||||
log: function (app) {
|
||||
assert.isTrue(!app.log);
|
||||
//
|
||||
// TODO: Assert winston.extend methods
|
||||
//
|
||||
}
|
||||
};
|
||||
|
||||
assert.log = {};
|
||||
|
||||
assert.log.levelMsgMeta = function (err, level, msg, meta) {
|
||||
assert.equal(level, this.event[1]);
|
||||
assert.equal(msg, this.event[2]);
|
||||
assert.equal(meta, this.event[3]);
|
||||
};
|
||||
|
||||
assert.log.msgMeta = function (err, level, msg, meta) {
|
||||
assert.equal(level, this.event[0].split('::')[1] || 'info');
|
||||
assert.equal(msg, this.event[1]);
|
||||
assert.equal(meta, this.event[2]);
|
||||
};
|
||||
|
||||
assert.log.levelMeta = function (err, level, msg, meta) {
|
||||
assert.equal(level, this.event[1]);
|
||||
assert.equal(msg, this.event[0]);
|
||||
assert.deepEqual(meta, this.event[2]);
|
||||
};
|
||||
|
||||
assert.log.levelMsg = function (err, level, msg, meta) {
|
||||
assert.equal(level, this.event[1]);
|
||||
assert.equal(msg, this.event[2]);
|
||||
};
|
||||
|
||||
assert.log.metaOnly = function (err, level, msg, meta, event) {
|
||||
assert.equal(level, 'info');
|
||||
assert.equal(msg, this.event[0]);
|
||||
assert.equal(meta, this.event[1]);
|
||||
assert.equal(event, this.event[0]);
|
||||
};
|
||||
24
node_modules/broadway/test/helpers/helpers.js
generated
vendored
Normal file
24
node_modules/broadway/test/helpers/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* helpers.js: Test helpers for using broadway.
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var events = require('eventemitter2'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
var helpers = exports;
|
||||
|
||||
helpers.findApp = function () {
|
||||
return Array.prototype.slice.call(arguments).filter(function (arg) {
|
||||
return arg instanceof events.EventEmitter2;
|
||||
})[0];
|
||||
};
|
||||
|
||||
helpers.mockApp = function () {
|
||||
var mock = new events.EventEmitter2({ delimiter: '::', wildcard: true });
|
||||
mock.options = {};
|
||||
return mock;
|
||||
};
|
||||
74
node_modules/broadway/test/helpers/macros.js
generated
vendored
Normal file
74
node_modules/broadway/test/helpers/macros.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* macros.js: Test macros for using broadway and vows
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var events = require('eventemitter2'),
|
||||
assert = require('./assert'),
|
||||
helpers = require('./helpers'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
var macros = exports;
|
||||
|
||||
macros.shouldExtend = function (app, plugin, vows) {
|
||||
if (arguments.length === 1) {
|
||||
plugin = app;
|
||||
app = vows = null;
|
||||
}
|
||||
else if (arguments.length === 2) {
|
||||
app = helpers.mockApp();
|
||||
vows = plugin;
|
||||
plugin = app;
|
||||
}
|
||||
|
||||
var context = {
|
||||
topic: function () {
|
||||
app = app || helpers.mockApp();
|
||||
broadway.plugins[plugin].attach.call(app, app.options[plugin] || {});
|
||||
|
||||
if (broadway.plugins[plugin].init) {
|
||||
return broadway.plugins[plugin].init.call(app, this.callback.bind(this, null, app));
|
||||
}
|
||||
|
||||
this.callback(null, app);
|
||||
},
|
||||
"should add the appropriate properties and methods": function (_, app) {
|
||||
assert.plugins.has[plugin](app);
|
||||
}
|
||||
}
|
||||
|
||||
return extendContext(context, vows);
|
||||
};
|
||||
|
||||
macros.shouldLogEvent = function (app, event, vow) {
|
||||
return {
|
||||
topic: function () {
|
||||
app = app || helpers.findApp.apply(null, arguments);
|
||||
var logger = app.log.get('default');
|
||||
|
||||
this.event = event;
|
||||
app.once('broadway::logged', this.callback.bind(this, null));
|
||||
app.emit.apply(app, event);
|
||||
},
|
||||
"should log the appropriate info": vow
|
||||
};
|
||||
};
|
||||
|
||||
function extendContext (context, vows) {
|
||||
if (vows) {
|
||||
if (vows.topic) {
|
||||
console.log('Cannot include topic at top-level of nested vows:');
|
||||
console.dir(vows, 'vows');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Object.keys(vows).forEach(function (key) {
|
||||
context[key] = vows[key];
|
||||
});
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
19
node_modules/broadway/test/plugins/config-test.js
generated
vendored
Normal file
19
node_modules/broadway/test/plugins/config-test.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* config-test.js: Tests for the broadway config plugin
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var vows = require('vows'),
|
||||
events = require('eventemitter2'),
|
||||
assert = require('../helpers/assert'),
|
||||
macros = require('../helpers/macros'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
vows.describe('broadway/plugins/config').addBatch({
|
||||
"Using the config plugin": {
|
||||
"extending an application": macros.shouldExtend('config')
|
||||
}
|
||||
}).export(module);
|
||||
28
node_modules/broadway/test/plugins/directories-test.js
generated
vendored
Normal file
28
node_modules/broadway/test/plugins/directories-test.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* directories-test.js: Tests for working with directories in broadway.
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
vows = require('vows'),
|
||||
broadway = require('../../lib/broadway'),
|
||||
macros = require('../helpers/macros');
|
||||
|
||||
var fixturesDir = path.join(__dirname, '..', 'fixtures'),
|
||||
emptyAppDir = path.join(fixturesDir, 'empty-app'),
|
||||
emptyAppFile = path.join(fixturesDir, 'sample-app.json'),
|
||||
appConfig = JSON.parse(fs.readFileSync(emptyAppFile, 'utf8'));;
|
||||
|
||||
vows.describe('broadway/plugins/directories').addBatch({
|
||||
"Using the config plugin": {
|
||||
"extending an application": macros.shouldExtend(new broadway.App({
|
||||
root: emptyAppDir,
|
||||
directories: appConfig.directories
|
||||
}), 'directories', {})
|
||||
}
|
||||
}).export(module);
|
||||
69
node_modules/broadway/test/plugins/log-test.js
generated
vendored
Normal file
69
node_modules/broadway/test/plugins/log-test.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* log-test.js: Tests for the broadway logger plugin
|
||||
*
|
||||
* (C) 2011, Nodejitsu Inc.
|
||||
* MIT LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
var vows = require('vows'),
|
||||
events = require('eventemitter2'),
|
||||
assert = require('../helpers/assert'),
|
||||
helpers = require('../helpers/helpers'),
|
||||
macros = require('../helpers/macros'),
|
||||
broadway = require('../../lib/broadway');
|
||||
|
||||
var app = helpers.mockApp();
|
||||
app.options = {
|
||||
log: {
|
||||
logAll: true,
|
||||
namespaces: {
|
||||
'apps': 'foo'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
vows.describe('broadway/plugins/log').addBatch({
|
||||
"Using the log plugin": {
|
||||
"to extend an application": macros.shouldExtend(app, 'log', {
|
||||
"when the application emits log::# events": macros.shouldLogEvent(app, [
|
||||
'log::warn',
|
||||
'some warn message',
|
||||
{ foo: 'bar' }
|
||||
], assert.log.msgMeta)
|
||||
}),
|
||||
"when the application emits log::#::# events": macros.shouldLogEvent(app, [
|
||||
'log::warn::some-category',
|
||||
'some warn message',
|
||||
{ foo: 'bar' }
|
||||
], assert.log.msgMeta),
|
||||
"when the application emits log events with": {
|
||||
"message and meta": macros.shouldLogEvent(app, [
|
||||
'log',
|
||||
'some info message',
|
||||
{ foo: 'bar' },
|
||||
], assert.log.msgMeta),
|
||||
"level and message": macros.shouldLogEvent(app, [
|
||||
'log',
|
||||
'silly',
|
||||
'some silly message',
|
||||
], assert.log.levelMsg),
|
||||
"level and meta": macros.shouldLogEvent(app, [
|
||||
'log',
|
||||
'info',
|
||||
{ foo: 'bar' },
|
||||
], assert.log.levelMeta)
|
||||
},
|
||||
"when the application emits namespaced events with": {
|
||||
"level and meta": macros.shouldLogEvent(app, [
|
||||
'apps::start',
|
||||
'info',
|
||||
{ foo: 'bar' },
|
||||
], assert.log.levelMeta),
|
||||
"meta only": macros.shouldLogEvent(app, [
|
||||
'apps::start',
|
||||
{ foo: 'bar' },
|
||||
], assert.log.metaOnly)
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
Reference in New Issue
Block a user