UNPKG

ts3-nodejs-library

Version:
1,212 lines (1,065 loc) 78.6 kB
const mockExecute = jest.fn() const mockExecutePrio = jest.fn() const mockTransfer = jest.fn() const mockClose = jest.fn() const mockIsConnected = jest.fn() jest.mock("../src/transport/TeamSpeakQuery", () => { const { TeamSpeakQuery } = jest.requireActual("../src/transport/TeamSpeakQuery") // tslint:disable-next-line: only-arrow-functions TeamSpeakQuery.getSocket = function() { // tslint:disable-next-line: no-empty return { on() {}, send() {}, sendKeepAlive() {}, close() { mockClose() }, isConnected() {} } } TeamSpeakQuery.prototype.execute = mockExecute TeamSpeakQuery.prototype.executePrio = mockExecutePrio TeamSpeakQuery.prototype.isConnected = mockIsConnected return { TeamSpeakQuery } }) jest.mock("../src/transport/FileTransfer", () => { class FileTransfer { download() { return mockTransfer(...arguments) } upload() { return mockTransfer(...arguments) } } return { FileTransfer } }) import { TeamSpeak, TextMessageTargetMode, LogLevel, ReasonIdentifier, TeamSpeakChannel, TeamSpeakServer, TeamSpeakClient, TeamSpeakServerGroup, TeamSpeakChannelGroup } from "../src" import * as mocks from "./mocks/queryresponse" import { ApiKeyScope, TokenType, ClientType } from "../src/types/enum" import { SelectType } from "../src/types/context" import { BanClient } from "../src/types/PropertyTypes" describe("TeamSpeak", () => { let teamspeak: TeamSpeak = new TeamSpeak({}) beforeEach(() => { teamspeak = new TeamSpeak({}) mockTransfer.mockReset() mockClose.mockReset() mockExecute.mockReset() mockExecute.mockResolvedValue([]) mockExecutePrio.mockReset() mockExecutePrio.mockResolvedValue([]) }) describe("#new()", () => { it("should test the construction of TeamSpeak with an empty object", () => { const teamspeak = new TeamSpeak({}) expect(teamspeak.config) .toEqual({ protocol: TeamSpeak.QueryProtocol.RAW, host: "127.0.0.1", ignoreQueries: false, queryport: 10011, readyTimeout: 10000, keepAlive: true, keepAliveTimeout: 250, autoConnect: true }) }) it("should test the construction of TeamSpeak with an username and password", () => { const teamspeak = new TeamSpeak({ username: "foo", password: "bar" }) expect(teamspeak.config) .toEqual({ protocol: TeamSpeak.QueryProtocol.RAW, host: "127.0.0.1", ignoreQueries: false, queryport: 10011, readyTimeout: 10000, keepAlive: true, keepAliveTimeout: 250, username: "foo", password: "bar", autoConnect: true }) }) it("should test the construction of TeamSpeak with protocol SSH", () => { const teamspeak = new TeamSpeak({ protocol: TeamSpeak.QueryProtocol.SSH }) expect(teamspeak.config) .toEqual({ protocol: TeamSpeak.QueryProtocol.SSH, host: "127.0.0.1", ignoreQueries: false, queryport: 10022, readyTimeout: 10000, keepAlive: true, keepAliveTimeout: 250, autoConnect: true }) }) it("should test the construction of TeamSpeak with a serverport", () => { const teamspeak = new TeamSpeak({ serverport: 5000 }) expect(teamspeak.config) .toEqual({ protocol: TeamSpeak.QueryProtocol.RAW, host: "127.0.0.1", ignoreQueries: false, queryport: 10011, readyTimeout: 10000, keepAlive: true, keepAliveTimeout: 250, serverport: 5000, autoConnect: true }) }) }) describe("#handleConnect()", () => { it("check an empty connection config", async () => { const teamspeak = new TeamSpeak({}) teamspeak["query"].emit("connect") expect(mockExecute).toHaveBeenCalledTimes(0) }) it("check a connection config with username and password", async () => { expect.assertions(3) const teamspeak = new TeamSpeak({ username: "foo", password: "bar" }) teamspeak["query"].emit("ready") expect(mockExecutePrio).toHaveBeenNthCalledWith(1, "login", ["foo", "bar"]) expect(mockExecutePrio).toHaveBeenNthCalledWith(2, "version") expect(mockExecutePrio).toHaveBeenCalledTimes(2) }) it("check a connection config with a serverport", async () => { expect.assertions(3) const teamspeak = new TeamSpeak({ serverport: 9987 }) teamspeak["query"].emit("ready") expect(mockExecutePrio).toHaveBeenNthCalledWith(1, "use", { port: 9987 }, ["-virtual"]) expect(mockExecutePrio).toHaveBeenNthCalledWith(2, "version") expect(mockExecutePrio).toHaveBeenCalledTimes(2) }) it("check a connection config with a serverport and nickname", async () => { expect.assertions(3) const teamspeak = new TeamSpeak({ serverport: 9987, nickname: "FooBar" }) teamspeak["query"].emit("ready") expect(mockExecutePrio).toHaveBeenNthCalledWith(1, "use", { port: 9987, clientNickname: "FooBar" }, ["-virtual"]) expect(mockExecutePrio).toHaveBeenNthCalledWith(2, "version") expect(mockExecutePrio).toHaveBeenCalledTimes(2) }) }) it("should validate correct subscriptions to events", () => { teamspeak.on("textmessage", () => null) expect(mockExecute).toHaveBeenCalledTimes(3) expect(mockExecute).toHaveBeenNthCalledWith(1, "servernotifyregister", { event: "textserver", id: undefined }) expect(mockExecute).toHaveBeenNthCalledWith(2, "servernotifyregister", { event: "textchannel", id: undefined }) expect(mockExecute).toHaveBeenNthCalledWith(3, "servernotifyregister", { event: "textprivate", id: undefined }) }) it("should validate that no events get registered", done => { expect.assertions(1) teamspeak["context"].events.push({ event: "textserver" }) teamspeak["context"].events.push({ event: "textchannel" }) teamspeak["context"].events.push({ event: "textprivate" }) teamspeak["context"].events.push({ event: "server" }) teamspeak["context"].events.push({ event: "channel", id: "0" }) teamspeak["context"].events.push({ event: "tokenused" }) teamspeak.on("clientconnect", () => null) teamspeak.on("clientdisconnect", () => null) teamspeak.on("serveredit", () => null) teamspeak.on("tokenused", () => null) teamspeak.on("channeledit", () => null) teamspeak.on("channelmoved", () => null) teamspeak.on("channelcreate", () => null) teamspeak.on("channeldelete", () => null) teamspeak.on("textmessage", () => null) process.nextTick(() => { expect(mockExecute).toHaveBeenCalledTimes(0) done() }) }) it("should test a #reconnect with selected SID", async () => { expect.assertions(2) mockExecutePrio.mockResolvedValue(null) mockIsConnected.mockReturnValue(true) teamspeak["context"].selectType = SelectType.SID teamspeak["context"].selected = 123 await teamspeak["handleReady"]() expect(mockExecutePrio).toHaveBeenNthCalledWith(1, "use", [123, "-virtual"], { clientNickname: undefined }) expect(mockExecutePrio).toBeCalledTimes(2) }, 1000) it("should test #reconnect()", async () => { expect.assertions(1) mockIsConnected.mockReturnValue(true) await expect(teamspeak.reconnect(1, 50)) .rejects.toEqual(new Error("already connected")) }) it("should test a failed #reconnect()", async () => { expect.assertions(1) mockIsConnected.mockReturnValue(false) await expect(teamspeak.reconnect(0, 50)) .rejects.toEqual(new Error("reconnecting failed after 0 attempt(s)")) }) it("should verify parameters of #version()", async () => { await teamspeak.version() expect(mockExecute).toHaveBeenCalledWith("version") expect(mockExecute).toHaveBeenCalledTimes(1) }) it("should verify parameters of #clientSetServerQueryLogin()", async () => { await teamspeak.clientSetServerQueryLogin("foo") expect(mockExecute).toHaveBeenCalledWith("clientsetserverquerylogin", { clientLoginName: "foo"}) expect(mockExecute).toHaveBeenCalledTimes(1) }) it("should verify parameters of #clientUpdate()", async () => { await teamspeak.clientUpdate({ clientNickname: "Test" }) expect(mockExecute).toHaveBeenCalledWith("clientupdate", { clientNickname: "Test"}) expect(mockExecute).toHaveBeenCalledTimes(1) }) describe("#registerEvent()", () => { it("should verify 2 parameters", async () => { await teamspeak.registerEvent("channel", "0") expect(mockExecute).toHaveBeenCalledWith("servernotifyregister", { event: "channel", id: "0" }) expect(mockExecute).toHaveBeenCalledTimes(1) }) it("should verify 1 parameter", async () => { await teamspeak.registerEvent("channel") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servernotifyregister", { event: "channel", id: undefined }) }) }) it("should verify parameters of #queryloginadd()", async () => { await teamspeak.queryLoginAdd("name", "3") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("queryloginadd", {clientLoginName: "name", cldbid: "3"}) }) it("should verify parameters of #querylogindel()", async () => { await teamspeak.queryLoginDel("3") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("querylogindel", { cldbid: "3" }) }) it("should verify parameters of #queryloginlist()", async () => { await teamspeak.queryLoginList("search", 0, 10) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("queryloginlist", { pattern: "search", start: 0, duration: 10 }, ["-count"]) }) it("should verify parameters of #apiKeyAdd()", async () => { await teamspeak.apiKeyAdd({ scope: ApiKeyScope.MANAGE }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("apikeyadd", { scope: "manage" }) }) it("should verify parameters of #apiKeyList()", async () => { await teamspeak.apiKeyList({ start: 10 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("apikeylist", { start: 10 }, ["-count"]) }) it("should verify parameters of #apiKeyDel()", async () => { await teamspeak.apiKeyDel("512") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("apikeydel", { id: "512" }) }) it("should verify parameters of #unregisterEvent()", async () => { await teamspeak.unregisterEvent() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servernotifyunregister") }) it("should verify parameters of #login()", async () => { await teamspeak.login("serveradmin", "password") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("login", ["serveradmin", "password"]) }) it("should verify parameters of #logout()", async () => { await teamspeak.logout() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("logout") }) it("should verify parameters of #hostInfo()", async () => { await teamspeak.hostInfo() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("hostinfo") }) it("should verify parameters of #instanceInfo()", async () => { await teamspeak.instanceInfo() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("instanceinfo") }) it("should verify parameters of #instanceEdit()", async () => { await teamspeak.instanceEdit({ "serverinstanceFiletransferPort": 30033 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("instanceedit", { "serverinstanceFiletransferPort": 30033 }) }) it("should verify parameters of #bindingList()", async () => { await teamspeak.bindingList() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("bindinglist") }) describe("#useByPort()", () => { it("should verify 2 parameters", async () => { await teamspeak.useByPort(9987, "Test") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("use", { port: 9987, clientNickname: "Test" }, ["-virtual"]) }) it("should verify 1 parameter", async () => { await teamspeak.useByPort(9987) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("use", { port: 9987, clientNickname: undefined }, ["-virtual"]) }) }) describe("#useBySid()", () => { it("should verify 2 parameters", async () => { await teamspeak.useBySid("1", "Test") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("use", ["1", "-virtual"], { clientNickname: "Test" }) }) it("should verify 1 parameter", async () => { await teamspeak.useBySid("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("use", ["1", "-virtual"], { clientNickname: undefined }) }) }) it("should verify parameters of #whoami()", async () => { await teamspeak.whoami() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("whoami") }) it("should verify rejection of #self()", async () => { expect.assertions(2) mockExecute.mockResolvedValueOnce({ clientId: 1 }) mockExecute.mockResolvedValueOnce([]) await expect(teamspeak.self()) .rejects.toEqual(new Error("could not find own query client")) expect(mockExecute).toHaveBeenCalledTimes(2) }) it("should verify parameters of #serverInfo()", async () => { await teamspeak.serverInfo() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverinfo") }) it("should verify parameters of #serverIdGetByPort()", async () => { await teamspeak.serverIdGetByPort(9987) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serveridgetbyport", { virtualserverPort: 9987 }) }) it("should verify parameters of #serverEdit()", async () => { await teamspeak.serverEdit({ virtualserverName: "Foo" }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serveredit", { virtualserverName: "Foo" }) }) it("should verify parameters of #serverProcessStop()", async () => { await teamspeak.serverProcessStop("Shutdown") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverprocessstop", { reasonmsg: "Shutdown" }) }) it("should verify parameters of #connectionInfo()", async () => { await teamspeak.connectionInfo() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverrequestconnectioninfo") }) it("should verify parameters of #serverCreate()", async () => { mockExecute.mockResolvedValueOnce([{ token: "servertoken", sid: "2" }]) mockExecute.mockResolvedValueOnce([{ virtualserverId: "2" }]) const { server, token } = await teamspeak.serverCreate({ virtualserverName: "Server Name" }) expect(server).toBeInstanceOf(TeamSpeakServer) expect(token).toBe("servertoken") expect(mockExecute).toHaveBeenCalledTimes(2) expect(mockExecute).toHaveBeenCalledWith("servercreate", { virtualserverName: "Server Name" }) }) it("should verify parameters of #serverDelete()", async () => { await teamspeak.serverDelete("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverdelete", { sid: "1" }) }) it("should verify parameters of #serverStart()", async () => { await teamspeak.serverStart("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverstart", { sid: "1" }) }) describe("#serverStop()", () => { it("should verify 2 parameters", async () => { await teamspeak.serverStop("1", "Shutdown") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverstop", { sid: "1", reasonmsg: "Shutdown" }) }) it("should verify 1 parameter", async () => { await teamspeak.serverStop("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("serverstop", { sid: "1", reasonmsg: undefined }) }) }) it("should verify parameters of #serverGroupsByClientId()", async () => { await teamspeak.serverGroupsByClientId("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupsbyclientid", { cldbid: ["1"] }) }) it("should verify parameters of #serverGroupCreate()", async () => { mockExecute.mockResolvedValue([{ sgid: "2" }]) const group = await teamspeak.serverGroupCreate("New Group", 1) expect(group).toBeInstanceOf(TeamSpeakServerGroup) expect(mockExecute).toHaveBeenCalledTimes(2) expect(mockExecute).toHaveBeenCalledWith("servergroupadd", { name: "New Group", type: 1 }) }) it("should verify parameters of #serverGroupClientList()", async () => { await teamspeak.serverGroupClientList("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupclientlist", { sgid: "1" }, ["-names"]) }) it("should verify parameters of #serverGroupAddClient()", async () => { await teamspeak.serverGroupAddClient(["1", "3"], "2") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupaddclient", { sgid: "2", cldbid: ["1", "3"] }) }) it("should verify parameters of #serverGroupDelClient()", async () => { await teamspeak.serverGroupDelClient(["1", "3"], "2") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupdelclient", { sgid: "2", cldbid: ["1", "3"] }) }) it("should verify parameters of #clientAddServerGroup()", async () => { await teamspeak.clientAddServerGroup("1", ["2", "5"]) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientaddservergroup", { sgid: ["2", "5"], cldbid: "1" }) }) it("should verify parameters of #clientDelServerGroup()", async () => { await teamspeak.clientDelServerGroup("1", ["2", "5"]) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientdelservergroup", { sgid: ["2", "5"], cldbid: "1" }) }) it("should verify parameters of #serverGroupDel()", async () => { await teamspeak.serverGroupDel("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupdel", { sgid: "1", force: false }) }) it("should verify parameters of #serverGroupCopy()", async () => { await teamspeak.serverGroupCopy("1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupcopy", { name: "foo", ssgid: "1", tsgid: "0", type: 1 }) }) it("should verify parameters of #serverGroupRename()", async () => { await teamspeak.serverGroupRename("1", "New Name") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergrouprename", { sgid: "1", name: "New Name" }) }) describe("#serverGroupPermList()", () => { it("should verify 2 parameters", async () => { await teamspeak.serverGroupPermList("2", true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergrouppermlist", { sgid: "2" }, ["-permsid"]) }) it("should verify 1 parameter", async () => { await teamspeak.serverGroupPermList("2") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergrouppermlist", { sgid: "2" }, [null]) }) }) it("should verify parameters of #serverGroupAddPerm() with permsid", async () => { await teamspeak.serverGroupAddPerm("2", { permname: "i_channel_subscribe_power", permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupaddperm", { sgid: "2", permsid: "i_channel_subscribe_power", permvalue: 25, permskip: false, permnegated: false }) }) it("should verify parameters of #serverGroupAddPerm() with permid", async () => { await teamspeak.serverGroupAddPerm("2", { permname: 11, permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupaddperm", { sgid: "2", permid: 11, permvalue: 25, permskip: false, permnegated: false }) }) it("should verify parameters of #serverGroupDelPerm() with permsid", async () => { await teamspeak.serverGroupDelPerm("2", "i_channel_subscribe_power") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupdelperm", { sgid: "2", permsid: "i_channel_subscribe_power" }) }) it("should verify parameters of #serverGroupDelPerm() with permid", async () => { await teamspeak.serverGroupDelPerm("2", 10) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servergroupdelperm", { sgid: "2", permid: 10 }) }) it("should verify parameters of #serverTempPasswordAdd()", async () => { await teamspeak.serverTempPasswordAdd({ duration: 60, pw: "pass", desc: "description", tcid: "0", tcpw: "" }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servertemppasswordadd", { duration: 60, pw: "pass", desc: "description", tcid: "0", tcpw: "" }) }) it("should verify parameters of #serverTempPasswordDel()", async () => { await teamspeak.serverTempPasswordDel("test") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servertemppassworddel", { pw: "test" }) }) it("should verify parameters of #serverTempPasswordList()", async () => { await teamspeak.serverTempPasswordList() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("servertemppasswordlist") }) describe("channelClientPermList()", () => { it("should verify parameters of #channelClientPermList() without permsid", async () => { await teamspeak.channelClientPermList("10", "12") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelclientpermlist", { cid: "10", cldbid: "12" }, [null]) }) it("should verify parameters of #channelClientPermList() with permsid", async () => { await teamspeak.channelClientPermList("10", "12", true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelclientpermlist", { cid: "10", cldbid: "12" }, ["-permsid"]) }) }) it("should verify parameters of #channelCreate()", async () => { mockExecute.mockResolvedValue([{ cid: "2" }]) const channel = await teamspeak.channelCreate("Channel Name") expect(channel).toBeInstanceOf(TeamSpeakChannel) expect(mockExecute).toHaveBeenCalledTimes(2) expect(mockExecute).toHaveBeenCalledWith("channelcreate", { channelName: "Channel Name" }) }) it("should verify parameters of #channelGroupCreate()", async () => { mockExecute.mockResolvedValue([{ cgid: "2" }]) const group = await teamspeak.channelGroupCreate("Channel Group Name", 0) expect(group).toBeInstanceOf(TeamSpeakChannelGroup) expect(mockExecute).toHaveBeenCalledTimes(2) expect(mockExecute).toHaveBeenCalledWith("channelgroupadd", { name: "Channel Group Name", type: 0 }) }) it("should verify parameters of #getChannelById()", async () => { mockExecute.mockResolvedValue(mocks.channellist(5)) const channel = await teamspeak.getChannelById("3") if (!channel) throw new Error("no channel received") expect(channel).toBeInstanceOf(TeamSpeakChannel) expect(channel.cid).toBe("3") expect(channel.name).toBe("Channel 3") }) it("should verify parameters of #getChannelByName()", async () => { mockExecute.mockResolvedValue(mocks.channellist(5)) const channel = await teamspeak.getChannelByName("Channel 3") if (!channel) throw new Error("no channel received") expect(channel).toBeInstanceOf(TeamSpeakChannel) expect(channel.cid).toBe("3") expect(channel.name).toBe("Channel 3") }) it("should verify parameters of #channelInfo()", async () => { await teamspeak.channelInfo("2") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelinfo", { cid: "2" }) }) it("should verify parameters of #channelMove()", async () => { await teamspeak.channelMove("10", "5") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelmove", { cid: "10", cpid: "5", order: 0 }) }) it("should verify parameters of #channelDelete()", async () => { await teamspeak.channelDelete("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channeldelete", { cid: "10", force: false }) }) it("should verify parameters of #channelEdit()", async () => { await teamspeak.channelEdit("1", { channelName: "new name" }) expect(mockExecute).toHaveBeenCalledTimes(2) expect(mockExecute).toHaveBeenNthCalledWith(2, "channeledit", { cid: "1", channelName: "new name" }) }) it("should verify parameters of #channelPermList() with permsid", async () => { await teamspeak.channelPermList("10", true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelpermlist", { cid: "10" }, ["-permsid"]) }) it("should verify parameters of #channelPermList() with permid", async () => { await teamspeak.channelPermList("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelpermlist", { cid: "10" }, [null]) }) it("should verify parameters of #channelSetPerm() with permsid", async () => { await teamspeak.channelSetPerm("10", { permname: "i_channel_subscribe_power", permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channeladdperm", { cid: "10", permsid: "i_channel_subscribe_power", permvalue: 25 }) }) it("should verify parameters of #channelSetPerm() with permid", async () => { await teamspeak.channelSetPerm("10", { permname: 11, permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channeladdperm", { cid: "10", permid: 11, permvalue: 25 }) }) it("should verify parameters of #channelSetPerms()", async () => { await teamspeak.channelSetPerms("5", [{ permsid: "i_channel_needed_modify_power", permvalue: 75 }]) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toBeCalledWith( "channeladdperm", { cid: "5" }, [{ permsid: "i_channel_needed_modify_power", permvalue: 75 }] ) }) it("should verify parameters of #channelDelPerm() with permsid", async () => { await teamspeak.channelDelPerm("10", "i_channel_subscribe_power") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channeldelperm", { cid: "10", permsid: "i_channel_subscribe_power" }) }) it("should verify parameters of #channelDelPerm() with permid", async () => { await teamspeak.channelDelPerm("10", 11) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channeldelperm", { cid: "10", permid: 11 }) }) it("should verify parameters of #getClientById()", async () => { mockExecute.mockResolvedValue(mocks.clientlist(5)) const client = await teamspeak.getClientById("3") if (!client) throw new Error("no client received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(client).toBeInstanceOf(TeamSpeakClient) expect(client.clid).toBe("3") }) it("should verify parameters of #getClientByDbid()", async () => { mockExecute.mockResolvedValue(mocks.clientlist(5)) const client = await teamspeak.getClientByDbid("4") if (!client) throw new Error("no client received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(client).toBeInstanceOf(TeamSpeakClient) expect(client.databaseId).toBe("4") }) it("should verify parameters of #getClientByUid()", async () => { mockExecute.mockResolvedValue(mocks.clientlist(5)) const client = await teamspeak.getClientByUid("foobar4=") if (!client) throw new Error("no client received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(client).toBeInstanceOf(TeamSpeakClient) expect(client.uniqueIdentifier).toBe("foobar4=") }) it("should verify parameters of #getClientByName()", async () => { mockExecute.mockResolvedValue(mocks.clientlist(5)) const client = await teamspeak.getClientByName("Client 3") if (!client) throw new Error("no client received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(client).toBeInstanceOf(TeamSpeakClient) expect(client.nickname).toBe("Client 3") }) it("should verify parameters of #clientEdit()", async () => { await teamspeak.clientEdit("10", { clientDescription: "foo", clientIsTalker: true }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientedit", { clid: "10", clientDescription: "foo", clientIsTalker: true }) }) it("should verify parameters of #clientFind()", async () => { await teamspeak.clientFind("foo") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientfind", { pattern: "foo" }) }) it("should verify parameters of #clientGetIds()", async () => { await teamspeak.clientGetIds("foo=") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientgetids", { cluid: "foo=" }) }) it("should verify parameters of #clientGetDbidFromUid()", async () => { await teamspeak.clientGetDbidFromUid("foo=") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientgetdbidfromuid", { cluid: "foo=" }) }) it("should verify parameters of #clientGetNameFromUid()", async () => { await teamspeak.clientGetNameFromUid("foo=") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientgetnamefromuid", { cluid: "foo=" }) }) it("should verify parameters of #clientGetUidFromClid()", async () => { await teamspeak.clientGetUidFromClid("20") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientgetuidfromclid", { clid: "20" }) }) it("should verify parameters of #clientGetNameFromDbid()", async () => { await teamspeak.clientGetNameFromDbid("20") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientgetnamefromdbid", { cldbid: "20" }) }) it("should verify parameters of #clientInfo()", async () => { await teamspeak.clientInfo("20") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientinfo", { clid: ["20"] }) }) it("should verify parameters of #clientDbList()", async () => { await teamspeak.clientDbList() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientdblist", { start: 0, duration: 1000 }, ["-count"]) }) it("should verify parameters of #clientDbList() without count", async () => { await teamspeak.clientDbList(0, 1000, false) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientdblist", { start: 0, duration: 1000 }, [null]) }) it("should verify parameters of #clientDbInfo()", async () => { await teamspeak.clientDbInfo("25") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientdbinfo", { cldbid: ["25"] }) }) it("should verify parameters of #clientKick()", async () => { await teamspeak.clientKick("10", ReasonIdentifier.KICK_CHANNEL, "Kicked from Channel", true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientkick", { clid: "10", reasonid: 4, reasonmsg: "Kicked from Channel" }, ["-continueonerror"]) }) it("should verify parameters of #clientMove()", async () => { await teamspeak.clientMove("25", "10", undefined, true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientmove", { clid: "25", cid: "10", cpw: undefined }, ["-continueonerror"]) }) it("should verify parameters of #clientPoke()", async () => { await teamspeak.clientPoke("10", "you have been poked") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientpoke", { clid: "10", msg: "you have been poked" }) }) it("should verify parameters of #clientPermList() with permsid", async () => { await teamspeak.clientPermList("10", true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientpermlist", { cldbid: "10" }, ["-permsid"]) }) it("should verify parameters of #clientPermList() with permid", async () => { await teamspeak.clientPermList("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientpermlist", { cldbid: "10" }, [null]) }) it("should verify parameters of #clientAddPerm() with permsid", async () => { await teamspeak.clientAddPerm("10", { permname: "i_channel_subscribe_power", permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientaddperm", { cldbid: "10", permsid: "i_channel_subscribe_power", permvalue: 25, permskip: false, permnegated: false }) }) it("should verify parameters of #clientAddPerm() with permid", async () => { await teamspeak.clientAddPerm("10", { permname: 11, permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientaddperm", { cldbid: "10", permid: 11, permvalue: 25, permskip: false, permnegated: false }) }) it("should verify parameters of #clientDelPerm() with permsid", async () => { await teamspeak.clientDelPerm("10", "i_channel_subscribe_power") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientdelperm", { cldbid: "10", permsid: "i_channel_subscribe_power" }) }) it("should verify parameters of #clientDelPerm() with permid", async () => { await teamspeak.clientDelPerm("10", 11) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("clientdelperm", { cldbid: "10", permid: 11 }) }) it("should verify parameters of #customSearch()", async () => { await teamspeak.customSearch("key", "fdsa") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("customsearch", { ident: "key", pattern: "fdsa" }) }) it("should verify parameters of #customInfo()", async () => { await teamspeak.customInfo("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("custominfo", { cldbid: "10" }) }) it("should verify parameters of #customDelete()", async () => { await teamspeak.customDelete("10", "key") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("customdelete", { cldbid: "10", ident: "key" }) }) it("should verify parameters of #customSet()", async () => { await teamspeak.customSet("10", "key", "value") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("customset", { cldbid: "10", ident: "key", value: "value" }) }) it("should verify parameters of #sendTextMessage()", async () => { await teamspeak.sendTextMessage("10", TextMessageTargetMode.CLIENT, "message to client chat") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("sendtextmessage", { target: "10", targetmode: 1, msg: "message to client chat" }) }) it("should verify parameters of #sendTextMessage() with TargetMode channel", async () => { await teamspeak.sendTextMessage("10", TextMessageTargetMode.CHANNEL, "message to channel chat") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("sendtextmessage", { target: "10", targetmode: 2, msg: "message to channel chat" }) }) it("should verify parameters of #sendChannelMessage() when being in the same channel", async () => { mockExecute .mockResolvedValueOnce([{ clientId: "1" }]) .mockResolvedValueOnce([{ clid: "1", cid: "10" }]) await teamspeak.sendChannelMessage("10", "test message") expect(mockExecute).toHaveBeenCalledTimes(3) expect(mockExecute).toHaveBeenNthCalledWith(1, "whoami") expect(mockExecute).toHaveBeenNthCalledWith(2, "clientlist", ["-uid", "-away", "-voice", "-times", "-groups", "-info", "-icon", "-country", "-ip", "-location"]) expect(mockExecute).toHaveBeenNthCalledWith(3, "sendtextmessage", { target: "10", targetmode: 2, msg: "test message" }) }) it("should verify parameters of #sendChannelMessage() when being in a different channel", async () => { mockExecute .mockResolvedValueOnce([{ clientId: "1" }]) .mockResolvedValueOnce([{ clid: "1", cid: "9" }]) await teamspeak.sendChannelMessage("10", "test message") expect(mockExecute).toHaveBeenCalledTimes(5) expect(mockExecute).toHaveBeenNthCalledWith(1, "whoami") expect(mockExecute).toHaveBeenNthCalledWith(2, "clientlist", ["-uid", "-away", "-voice", "-times", "-groups", "-info", "-icon", "-country", "-ip", "-location"]) expect(mockExecute).toHaveBeenNthCalledWith(3, "clientmove", { cid: "10", clid: "1", cpw: undefined }, []) expect(mockExecute).toHaveBeenNthCalledWith(4, "sendtextmessage", { target: "10", targetmode: 2, msg: "test message" }) expect(mockExecute).toHaveBeenNthCalledWith(5, "clientmove", { cid: "9", clid: "1", cpw: undefined }, []) }) it("should verify parameters of #getServerGroupByID()", async () => { mockExecute.mockResolvedValue(mocks.servergrouplist(5)) const group = await teamspeak.getServerGroupById("4") if (!group) throw new Error("no group received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(group).toBeInstanceOf(TeamSpeakServerGroup) expect(group.sgid).toBe("4") }) it("should verify parameters of #getServerGroupByName()", async () => { mockExecute.mockResolvedValue(mocks.servergrouplist(5)) const group = await teamspeak.getServerGroupByName("Group 4") if (!group) throw new Error("no group received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(group).toBeInstanceOf(TeamSpeakServerGroup) expect(group.name).toBe("Group 4") }) it("should verify parameters of #getChannelGroupByID()", async () => { mockExecute.mockResolvedValue(mocks.channelgrouplist(5)) const group = await teamspeak.getChannelGroupById("4") if (!group) throw new Error("no group received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(group).toBeInstanceOf(TeamSpeakChannelGroup) expect(group.cgid).toBe("4") }) it("should verify parameters of #getChannelGroupByName()", async () => { mockExecute.mockResolvedValue(mocks.channelgrouplist(5)) const group = await teamspeak.getChannelGroupByName("Group 3") if (!group) throw new Error("no group received") expect(mockExecute).toHaveBeenCalledTimes(1) expect(group).toBeInstanceOf(TeamSpeakChannelGroup) expect(group!.name).toBe("Group 3") }) it("should verify parameters of #setClientChannelGroup()", async () => { await teamspeak.setClientChannelGroup("10", "5", "3") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("setclientchannelgroup", { cgid: "10", cid: "5", cldbid: "3" }) }) it("should verify parameters of #deleteChannelGroup()", async () => { await teamspeak.deleteChannelGroup("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupdel", { cgid: "10", force: false }) }) it("should verify parameters of #channelGroupCopy()", async () => { await teamspeak.channelGroupCopy("10", "0", 1, "New Channel Group") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupcopy", { scgid: "10", tcgid: "0", type: 1, name: "New Channel Group" }) }) it("should verify parameters of #channelGroupCopy() with name", async () => { await teamspeak.channelGroupCopy("10", "0", 1, "New Channel Group") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupcopy", { scgid: "10", tcgid: "0", type: 1, name: "New Channel Group" }) }) it("should verify parameters of #channelGroupRename()", async () => { await teamspeak.channelGroupRename("10", "New Name") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgrouprename", { cgid: "10", name: "New Name" }) }) it("should verify parameters of #channelGroupPermList() with permsid", async () => { await teamspeak.channelGroupPermList("10", true) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgrouppermlist", { cgid: "10" }, ["-permsid"]) }) it("should verify parameters of #channelGroupPermList() with permid", async () => { await teamspeak.channelGroupPermList("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgrouppermlist", { cgid: "10" }, [null]) }) it("should verify parameters of #channelGroupAddPerm() with permsid", async () => { await teamspeak.channelGroupAddPerm("10", { permname: "i_channel_subscribe_power", permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupaddperm", { cgid: "10", permsid: "i_channel_subscribe_power", permvalue: 25, permskip: false, permnegated: false }) }) it("should verify parameters of #channelGroupAddPerm() with permid", async () => { await teamspeak.channelGroupAddPerm("10", { permname: 11, permvalue: 25 }) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupaddperm", { cgid: "10", permid: 11, permvalue: 25, permskip: false, permnegated: false }) }) it("should verify parameters of #channelGroupDelPerm() with permsid", async () => { await teamspeak.channelGroupDelPerm("10", "i_channel_subscribe_power") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupdelperm", { cgid: "10", permsid: "i_channel_subscribe_power" }) }) it("should verify parameters of #channelGroupDelPerm() with permid", async () => { await teamspeak.channelGroupDelPerm("10", 11) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupdelperm", { cgid: "10", permid: 11 }) }) it("should verify parameters of #channelGroupClientList()", async () => { await teamspeak.channelGroupClientList("10", "5", "1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupclientlist", { cgid: "10", cid: "5", cldbid: "1" }) }) it("should verify parameters of #channelGroupClientList() without cldbid", async () => { await teamspeak.channelGroupClientList("10", "5") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupclientlist", { cgid: "10" , cid: "5" }) }) it("should verify parameters of #channelGroupClientList() without cid and cldbid", async () => { await teamspeak.channelGroupClientList("10") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("channelgroupclientlist", { cgid: "10" }) }) it("should verify parameters of #permOverview()", async () => { await teamspeak.permOverview("10", "5") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permoverview", { cldbid: "10", cid: "5" }) }) it("should verify parameters of #permOverview() with permsid", async () => { await teamspeak.permOverview("10", "5", ["a", "b", "c"]) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permoverview", { cldbid: "10", cid: "5", permsid: ["a", "b", "c"] }) }) it("should verify parameters of #permOverview() with permids", async () => { await teamspeak.permOverview("10", "5", [1, 2, 3]) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permoverview", { cldbid: "10", cid: "5", permid: [1, 2, 3] }) }) it("should verify parameters of #permissionList()", async () => { await teamspeak.permissionList() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permissionlist") }) it("should verify parameters of #permIdGetByName()", async () => { await teamspeak.permIdGetByName("b_foo") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permidgetbyname", { permsid: "b_foo" }) }) it("should verify parameters of #permIdsGetByName()", async () => { await teamspeak.permIdsGetByName(["b_foo", "b_bar"]) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permidgetbyname", { permsid: ["b_foo", "b_bar"] }) }) describe("#permGet()", () => { it("should verify with string parameter", async () => { await teamspeak.permGet("i_channel_subscribe_power") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permget", { permsid: "i_channel_subscribe_power" }) }) it("should verify with numeric parameter", async () => { await teamspeak.permGet(10) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permget", { permid: 10 }) }) }) describe("#permFind()", () => { it("should verify with string parameter", async () => { await teamspeak.permFind("i_channel_subscribe_power") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permfind", { permsid: "i_channel_subscribe_power" }) }) it("should verify with numeric parameter", async () => { await teamspeak.permFind(10) expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permfind", { permid: 10 }) }) }) it("should verify parameters of #permReset()", async () => { await teamspeak.permReset() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("permreset") }) it("should verify parameters of #privilegeKeyList()", async () => { await teamspeak.privilegeKeyList() expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("privilegekeylist") }) it("should verify parameters of #privilegeKeyAdd()", async () => { await teamspeak.privilegeKeyAdd(TokenType.ServerGroup, "10", undefined, "Server Group Token") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("privilegekeyadd", { tokentype: 0, tokenid1: "10", tokenid2: "0", tokendescription: "Server Group Token", tokencustomset: "" }) }) it("should verify some parameters of #privilegeKeyAdd()", async () => { await teamspeak.privilegeKeyAdd(TokenType.ChannelGroup, "10", "1") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("privilegekeyadd", { tokentype: 1, tokenid1: "10", tokenid2: "1", tokendescription: "", tokencustomset: "" }) }) it("should verify parameters of #serverGroupPrivilegeKeyAdd()", async () => { await teamspeak.serverGroupPrivilegeKeyAdd("10", "Server Group Token") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("privilegekeyadd", { tokentype: 0, tokenid1: "10", tokenid2: "0", tokendescription: "Server Group Token", tokencustomset: "" }) }) it("should verify parameters of #channelGroupPrivilegeKeyAdd()", async () => { await teamspeak.channelGroupPrivilegeKeyAdd("10", "5", "Channel Group Token") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHaveBeenCalledWith("privilegekeyadd", { tokentype: 1, tokenid1: "10", tokenid2: "5", tokendescription: "Channel Group Token", tokencustomset: "" }) }) it("should verify parameters of #privilegeKeyDelete()", async () => { await teamspeak.privilegeKeyDelete("asdf") expect(mockExecute).toHaveBeenCalledTimes(1) expect(mockExecute).toHav