Fix tests for mode shorthand commands
This commit is contained in:
parent
4dacaa46f3
commit
e0e12c1960
@ -42,7 +42,7 @@ exports.input = function ({irc, nick}, chan, cmd, args) {
|
|||||||
devoice: "-v",
|
devoice: "-v",
|
||||||
}[cmd];
|
}[cmd];
|
||||||
|
|
||||||
const limit = parseInt(irc.network.supports("modes")) || 1;
|
const limit = parseInt(irc.network.supports("MODES")) || 1;
|
||||||
|
|
||||||
for (let i = 0; i < target.length; i += limit) {
|
for (let i = 0; i < target.length; i += limit) {
|
||||||
const targets = target.slice(i, i + limit);
|
const targets = target.slice(i, i + limit);
|
||||||
|
@ -20,6 +20,13 @@ describe("Commands", function () {
|
|||||||
lastCommand: null,
|
lastCommand: null,
|
||||||
nick: "xPaw",
|
nick: "xPaw",
|
||||||
irc: {
|
irc: {
|
||||||
|
network: {
|
||||||
|
supports(type) {
|
||||||
|
if (type.toUpperCase() === "MODES") {
|
||||||
|
return "4";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
raw(...args) {
|
raw(...args) {
|
||||||
testableNetwork.lastCommand = args.join(" ");
|
testableNetwork.lastCommand = args.join(" ");
|
||||||
},
|
},
|
||||||
@ -82,9 +89,18 @@ describe("Commands", function () {
|
|||||||
ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw"]);
|
ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw"]);
|
||||||
expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v xPaw");
|
expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v xPaw");
|
||||||
|
|
||||||
// Multiple arguments are supported, sent as separate commands
|
ModeCommand.input(testableNetwork, channel, "voice", ["xPaw", "Max-P"]);
|
||||||
ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw", "Max-P"]);
|
expect(testableNetwork.lastCommand).to.equal("MODE #thelounge +vv xPaw Max-P");
|
||||||
expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v Max-P");
|
|
||||||
|
// since the limit for modes on tests is 4, it should send two commands
|
||||||
|
ModeCommand.input(testableNetwork, channel, "devoice", [
|
||||||
|
"xPaw",
|
||||||
|
"Max-P",
|
||||||
|
"hey",
|
||||||
|
"idk",
|
||||||
|
"thelounge",
|
||||||
|
]);
|
||||||
|
expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v thelounge");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user