From e0e12c196049e6609a5ddd40f0b47edd627a8a66 Mon Sep 17 00:00:00 2001 From: JeDaYoshi Date: Sat, 3 Jul 2021 21:20:28 +0000 Subject: [PATCH] Fix tests for mode shorthand commands --- src/plugins/inputs/mode.js | 2 +- test/commands/mode.js | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/plugins/inputs/mode.js b/src/plugins/inputs/mode.js index a86f3e26..9af07079 100644 --- a/src/plugins/inputs/mode.js +++ b/src/plugins/inputs/mode.js @@ -42,7 +42,7 @@ exports.input = function ({irc, nick}, chan, cmd, args) { devoice: "-v", }[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) { const targets = target.slice(i, i + limit); diff --git a/test/commands/mode.js b/test/commands/mode.js index ab27a9a4..c85cafaf 100644 --- a/test/commands/mode.js +++ b/test/commands/mode.js @@ -20,6 +20,13 @@ describe("Commands", function () { lastCommand: null, nick: "xPaw", irc: { + network: { + supports(type) { + if (type.toUpperCase() === "MODES") { + return "4"; + } + }, + }, raw(...args) { testableNetwork.lastCommand = args.join(" "); }, @@ -82,9 +89,18 @@ describe("Commands", function () { ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw"]); expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v xPaw"); - // Multiple arguments are supported, sent as separate commands - ModeCommand.input(testableNetwork, channel, "devoice", ["xPaw", "Max-P"]); - expect(testableNetwork.lastCommand).to.equal("MODE #thelounge -v Max-P"); + ModeCommand.input(testableNetwork, channel, "voice", ["xPaw", "Max-P"]); + expect(testableNetwork.lastCommand).to.equal("MODE #thelounge +vv xPaw 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"); }); }); });