mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
Basic test script setup
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
var Discord = require("../");
|
var Discord = require("../");
|
||||||
var client = new Discord.Client();
|
var client = new Discord.Client();
|
||||||
var colors = require("colors");
|
var colors = require("colors");
|
||||||
|
var fs = require("fs");
|
||||||
|
|
||||||
var passes = 0, fails = 0;
|
var passes = 0, fails = 0;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ function pass(msg) {
|
|||||||
|
|
||||||
function err(msg) {
|
function err(msg) {
|
||||||
console.log(" ✗ ".red + msg);
|
console.log(" ✗ ".red + msg);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Beginning Lib Test".yellow);
|
console.log("Beginning Lib Test".yellow);
|
||||||
@@ -102,7 +104,7 @@ function makeChannel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function editChannel() {
|
function editChannel() {
|
||||||
section("Channel Editting");
|
section("Channel Manipulation");
|
||||||
|
|
||||||
client.setChannelNameAndTopic(channel, "testing", "a testing channel - temporary").then(() => {
|
client.setChannelNameAndTopic(channel, "testing", "a testing channel - temporary").then(() => {
|
||||||
|
|
||||||
@@ -158,6 +160,100 @@ function editMsg() {
|
|||||||
|
|
||||||
client.updateMessage(message, client.user + channel + server).then(msg => {
|
client.updateMessage(message, client.user + channel + server).then(msg => {
|
||||||
|
|
||||||
|
if (!msg) {
|
||||||
|
err("message not passed back on update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.content !== client.user.mention() + channel.mention() + server.name) {
|
||||||
|
err("message content not what expected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pass("message updated");
|
||||||
|
pass("message content was as expected - complex");
|
||||||
|
|
||||||
|
client.deleteMessage(message).then(() => {
|
||||||
|
pass("message deleted");
|
||||||
|
sendFile();
|
||||||
|
}).catch(e => {
|
||||||
|
err("error deleting message: " + e)
|
||||||
|
});
|
||||||
|
|
||||||
|
}).catch(e => {
|
||||||
|
err("error updating message: " + e)
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendFile() {
|
||||||
|
section("File Sending & Deletion");
|
||||||
|
|
||||||
|
client.sendFile(channel, "./test/image.png", "image.png").then(file => {
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
err("file not passed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.attachments.length === 0) {
|
||||||
|
err("attachment not added");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pass("sent attachment file");
|
||||||
|
|
||||||
|
client.deleteMessage(file).then(() => {
|
||||||
|
pass("message deleted");
|
||||||
|
deleteAll();
|
||||||
|
}).catch(e => {
|
||||||
|
err("error deleting message: " + e)
|
||||||
|
});
|
||||||
|
|
||||||
|
}).catch(e => {
|
||||||
|
err("error sending file: " + e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAll() {
|
||||||
|
|
||||||
|
section("Clean Up");
|
||||||
|
|
||||||
|
client.deleteChannel(channel).then(() => {
|
||||||
|
|
||||||
|
pass("deleted temporary channel");
|
||||||
|
|
||||||
|
client.leaveServer(server).then(() => {
|
||||||
|
|
||||||
|
pass("deleted temporary server");
|
||||||
|
|
||||||
|
exit();
|
||||||
|
|
||||||
|
}).catch(e => {
|
||||||
|
err("error deleting server: " + e);
|
||||||
|
});
|
||||||
|
|
||||||
|
}).catch(e => {
|
||||||
|
err("error deleting channel: " + e);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function exit() {
|
||||||
|
|
||||||
|
section("Exiting");
|
||||||
|
|
||||||
|
client.logout().then(() => {
|
||||||
|
pass("logged out");
|
||||||
|
done();
|
||||||
|
}).catch(e => {
|
||||||
|
err("couldn't log out: " + e);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function done() {
|
||||||
|
section("Report");
|
||||||
|
pass("all tests done");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user