|
|
@ -4,6 +4,14 @@ const mockobjects = require('./mockobjects.js'),
|
|
|
|
rewire = require('rewire');
|
|
|
|
rewire = require('rewire');
|
|
|
|
let Discord = require("discord.js");
|
|
|
|
let Discord = require("discord.js");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mockobjects.mockLogger = {
|
|
|
|
|
|
|
|
error: () => {},
|
|
|
|
|
|
|
|
warn: () => {},
|
|
|
|
|
|
|
|
info: () => {},
|
|
|
|
|
|
|
|
verbose: () => {},
|
|
|
|
|
|
|
|
debug: () => {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
describe('lib/utils', function() {
|
|
|
|
describe('lib/utils', function() {
|
|
|
|
const utils = require('../lib/utils.js');
|
|
|
|
const utils = require('../lib/utils.js');
|
|
|
|
|
|
|
|
|
|
|
@ -210,13 +218,12 @@ describe('lib/music', function() {
|
|
|
|
let dj = new music.DJ(mockobjects.mockVoicechannel);
|
|
|
|
let dj = new music.DJ(mockobjects.mockVoicechannel);
|
|
|
|
dj.connect().then(() => {
|
|
|
|
dj.connect().then(() => {
|
|
|
|
dj.playYouTube('http://www.youtube.com/watch?v=ABCDEFGHIJK');
|
|
|
|
dj.playYouTube('http://www.youtube.com/watch?v=ABCDEFGHIJK');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
assert(dj.playing);
|
|
|
|
assert(dj.playing);
|
|
|
|
done();
|
|
|
|
done();
|
|
|
|
}, 100);
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('gets the video name', function (done) {
|
|
|
|
it('gets the video name', function (done) {
|
|
|
|
let dj = new music.DJ(mockobjects.mockVoicechannel);
|
|
|
|
let dj = new music.DJ(mockobjects.mockVoicechannel);
|
|
|
@ -350,6 +357,7 @@ describe('lib/cmd', function() {
|
|
|
|
|
|
|
|
|
|
|
|
describe('lib/guilding', function() {
|
|
|
|
describe('lib/guilding', function() {
|
|
|
|
const guilding = rewire('../lib/guilding');
|
|
|
|
const guilding = rewire('../lib/guilding');
|
|
|
|
|
|
|
|
const servercommands = require('../commands/servercommands');
|
|
|
|
guilding.__set__("sqlite3", null);
|
|
|
|
guilding.__set__("sqlite3", null);
|
|
|
|
guilding.__set__("utils", {
|
|
|
|
guilding.__set__("utils", {
|
|
|
|
dirExistence: (file, callback) => {
|
|
|
|
dirExistence: (file, callback) => {
|
|
|
@ -436,5 +444,32 @@ describe('lib/guilding', function() {
|
|
|
|
done();
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('handles all servercommands', function() {
|
|
|
|
|
|
|
|
let gh = new guilding.GuildHandler('test', '~');
|
|
|
|
|
|
|
|
gh.db = new mockobjects.MockDatabase('', ()=>{});
|
|
|
|
|
|
|
|
gh.registerMusicCommands();
|
|
|
|
|
|
|
|
gh.ready = true;
|
|
|
|
|
|
|
|
let msgSpy = sinon.spy();
|
|
|
|
|
|
|
|
let msg = {
|
|
|
|
|
|
|
|
content: 'test',
|
|
|
|
|
|
|
|
author: {
|
|
|
|
|
|
|
|
tag: undefined
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
reply: msgSpy,
|
|
|
|
|
|
|
|
channel: {
|
|
|
|
|
|
|
|
send: msgSpy
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let category of Object.keys(servercommands)) {
|
|
|
|
|
|
|
|
for (let command of Object.keys(servercommands[category])) {
|
|
|
|
|
|
|
|
msg.content = '~' + command;
|
|
|
|
|
|
|
|
gh.handleMessage(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(msgSpy.called);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|