Added Test

- testing all servercommands in guilding
pull/26/head
Trivernis 6 years ago
parent b7e66f8fd5
commit 249c711b53

@ -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,12 +218,11 @@ 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(() => {
assert(dj.playing);
done();
}, 100);
}); });
setTimeout(() => {
assert(dj.playing);
done();
}, 100);
}); });
it('gets the video name', function (done) { it('gets the video name', function (done) {
@ -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);
});
}); });
}); });
Loading…
Cancel
Save