Skip to content

Commit

Permalink
updated to new test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddieSanchez committed Nov 28, 2015
1 parent 1406839 commit c0339eb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/listeners/message/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Array.prototype.flatMap = function(lambda) {
function loadHelp() {
var help = fs.readdirSync(__dirname +'/../').flatMap(function(eventName) {
var filepath = __dirname + '/../' + eventName;

// all js files that have exported 'help'
var files = fs.readdirSync(filepath).filter(
function(file) {
return /^[^\.].*.js$/.test(file) &&
require(filepath + '/' + file).help;
});
});
return files.flatMap(
function(file) {
var f = require(filepath + '/' + file);
Expand All @@ -23,9 +25,11 @@ function loadHelp() {
return help;
}
function messageListener(db, from, channel, message) {

if (/^@help$/.test(message)) {
var help = loadHelp();
return [ { to: channel, message: 'available commands: ' + help.map(function(h) { return h.cmd; }).join(', ')}];
return [ { to: channel,
message: 'Available commands: ' + help.map(function(h) { return h.cmd; }).join(', ')}];
}
if (/^@help\s+(.+)$/.test(message)) {

Expand Down
3 changes: 2 additions & 1 deletion lib/listeners/message/krypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function messageListener(db, from, channel, message) {
module.exports = messageListener;
module.exports.help = [{ cmd:'@krypto',
syntax: '@krypto',
output: {success: ['<user>: OK - take a guess.','<card>, <card>, <card>, <card>, <card> Objective Card: <card>'],
output: {success: ['<user>: OK - take a guess.',
'<card>, <card>, <card>, <card>, <card> Objective Card: <card>'],
failure: ['<user>: Sorry, but <user> already is guessing.']}
},
{cmd: '@cards',
Expand Down
1 change: 0 additions & 1 deletion lib/listeners/message/tell.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ function messageListener(db, from, channel, message) {
}

module.exports = messageListener;

1 change: 0 additions & 1 deletion lib/say-slowly.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

function say_slowly(say, channel, messages) {

var msg = messages.shift();

if (msg) {
Expand Down
13 changes: 12 additions & 1 deletion test/sectry_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var sectery = require('../lib/sectery');
var utilities = require('../lib/utilities');
<<<<<<< HEAD
var krypto = require('../lib/krypto-game');
var irc = require('irc');

Expand Down Expand Up @@ -470,4 +469,16 @@ describe('sectery', function () {
var command = '@poll ' + command + ' ' + id;
testUser.message(command);
});

it('@help', function(done) {

var command = '@help';

testUser.expectM(done, secteryUser.nick(), function (x) {
var regex = new RegExp('Available commands: .*');
log(x,regex);
return regex.test(x);
});
testUser.message(command);
});
});

0 comments on commit c0339eb

Please sign in to comment.