ts3-nodejs-library
Version:
TeamSpeak Server Query API
1,254 lines (1,093 loc) • 69.5 kB
text/typescript
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")
TeamSpeakQuery.getSocket = function() {
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 {
constructor() {}
download() {
return mockTransfer(...arguments)
}
upload() {
return mockTransfer(...arguments)
}
}
return { FileTransfer }
})
import {
TeamSpeak,
QueryProtocol,
TextMessageTargetMode,
LogLevel,
ReasonIdentifier,
TeamSpeakChannel,
TeamSpeakServer,
TeamSpeakClient,
TeamSpeakServerGroup,
TeamSpeakChannelGroup
} from "../src"
import * as mocks from "./mocks/queryresponse"
describe("TeamSpeak", () => {
let teamspeak: TeamSpeak = new TeamSpeak({})
beforeEach(() => {
teamspeak = new TeamSpeak({})
mockTransfer.mockReset()
mockClose.mockReset()
mockExecute.mockReset()
mockExecute.mockResolvedValue(null)
mockExecutePrio.mockReset()
mockExecutePrio.mockResolvedValue(null)
})
describe("#new()", () => {
it("should test the construction of TeamSpeak with an empty object", () => {
let teamspeak = new TeamSpeak({})
expect(teamspeak.config)
.toEqual({
protocol: QueryProtocol.RAW,
host: "127.0.0.1",
queryport: 10011,
readyTimeout: 10000,
keepAlive: true,
autoConnect: true
})
})
it("should test the construction of TeamSpeak with an username and password", () => {
let teamspeak = new TeamSpeak({ username: "foo", password: "bar" })
expect(teamspeak.config)
.toEqual({
protocol: QueryProtocol.RAW,
host: "127.0.0.1",
queryport: 10011,
readyTimeout: 10000,
keepAlive: true,
username: "foo",
password: "bar",
autoConnect: true
})
})
it("should test the construction of TeamSpeak with protocol SSH", () => {
let teamspeak = new TeamSpeak({ protocol: QueryProtocol.SSH })
expect(teamspeak.config)
.toEqual({
protocol: QueryProtocol.SSH,
host: "127.0.0.1",
queryport: 10022,
readyTimeout: 10000,
keepAlive: true,
autoConnect: true
})
})
it("should test the construction of TeamSpeak with a serverport", () => {
let teamspeak = new TeamSpeak({ serverport: 5000 })
expect(teamspeak.config)
.toEqual({
protocol: QueryProtocol.RAW,
host: "127.0.0.1",
queryport: 10011,
readyTimeout: 10000,
keepAlive: true,
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(2)
const teamspeak = new TeamSpeak({ username: "foo", password: "bar" })
teamspeak["query"].emit("ready")
expect(mockExecutePrio).toBeCalledWith("login", ["foo", "bar"])
expect(mockExecutePrio).toHaveBeenCalledTimes(1)
})
it("check a connection config with a serverport", async () => {
expect.assertions(2)
const teamspeak = new TeamSpeak({ serverport: 9987 })
teamspeak["query"].emit("ready")
expect(mockExecutePrio).toBeCalledWith("use", { port: 9987 }, ["-virtual"])
expect(mockExecutePrio).toHaveBeenCalledTimes(1)
})
it("check a connection config with a serverport and nickname", async () => {
expect.assertions(2)
const teamspeak = new TeamSpeak({ serverport: 9987, nickname: "FooBar" })
teamspeak["query"].emit("ready")
expect(mockExecutePrio).toBeCalledWith("use", { port: 9987, client_nickname: "FooBar" }, ["-virtual"])
expect(mockExecutePrio).toHaveBeenCalledTimes(1)
})
})
it("should test #reconnect()", async () => {
expect.assertions(1)
mockIsConnected.mockReturnValue(true)
await expect(teamspeak.reconnect(1)).rejects.toEqual(new Error("already connected"))
})
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", { client_login_name: "foo"})
expect(mockExecute).toHaveBeenCalledTimes(1)
})
it("should verify parameters of #clientUpdate()", async () => {
await teamspeak.clientUpdate({ client_nickname: "Test" })
expect(mockExecute).toHaveBeenCalledWith("clientupdate", { client_nickname: "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", {client_login_name: "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 #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({ "serverinstance_filetransfer_port": 30033 })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("instanceedit", { "serverinstance_filetransfer_port": 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, client_nickname: "Test" }, ["-virtual"])
})
it("should verify 1 parameter", async () => {
await teamspeak.useByPort(9987)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("use", { port: 9987, client_nickname: 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"], { client_nickname: "Test" })
})
it("should verify 1 parameter", async () => {
await teamspeak.useBySid(1)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("use", [1, "-virtual"], { client_nickname: undefined })
})
})
it("should verify parameters of #whoami()", async () => {
await teamspeak.whoami()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("whoami")
})
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", { virtualserver_port: 9987 })
})
it("should verify parameters of #serverEdit()", async () => {
await teamspeak.serverEdit({ virtualserver_name: "Foo" })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("serveredit", { virtualserver_name: "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([{ virtualserver_id: 2 }])
const { server, token } = await teamspeak.serverCreate({ virtualserver_name: "Server Name" })
expect(server).toBeInstanceOf(TeamSpeakServer)
expect(token).toBe("servertoken")
expect(mockExecute).toHaveBeenCalledTimes(2)
expect(mockExecute).toHaveBeenCalledWith("servercreate", { virtualserver_name: "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: 0 })
})
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, "i_channel_subscribe_power", 25)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("servergroupaddperm", {
sgid: 2,
permsid: "i_channel_subscribe_power",
permvalue: 25,
permskip: 0,
permnegated: 0
})
})
it("should verify parameters of #serverGroupAddPerm() with permid", async () => {
await teamspeak.serverGroupAddPerm(2, 11, 25)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("servergroupaddperm", {
sgid: 2,
permid: 11,
permvalue: 25,
permskip: 0,
permnegated: 0
})
})
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", { channel_name: "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)
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")
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: 0 })
})
it("should verify parameters of #channelEdit()", async () => {
await teamspeak.channelEdit(1, { channel_name: "new name" })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("channeledit", { cid: 1, channel_name: "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, "i_channel_subscribe_power", 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, 11, 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)
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)
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=")
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")
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, { client_description: "foo", client_is_talker: 1 })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientedit", { clid: 10, client_description: "foo", client_is_talker: 1 })
})
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")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientkick", {
clid: 10,
reasonid: 4,
reasonmsg: "Kicked from Channel"
})
})
it("should verify parameters of #clientMove()", async () => {
await teamspeak.clientMove(25, 10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientmove", { clid: 25, cid: 10, cpw: undefined })
})
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, "i_channel_subscribe_power", 25)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientaddperm", {
cldbid: 10,
permsid: "i_channel_subscribe_power",
permvalue: 25,
permskip: 0,
permnegated: 0
})
})
it("should verify parameters of #clientAddPerm() with permid", async () => {
await teamspeak.clientAddPerm(10, 11, 25)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientaddperm", {
cldbid: 10,
permid: 11,
permvalue: 25,
permskip: 0,
permnegated: 0
})
})
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 channel chat")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("sendtextmessage", {
target: 10,
targetmode: 1,
msg: "message to channel chat"
})
})
it("should verify parameters of #getServerGroupByID()", async () => {
mockExecute.mockResolvedValue(mocks.servergrouplist(5))
const group = await teamspeak.getServerGroupByID(4)
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")
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)
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")
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: 0 })
})
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, "i_channel_subscribe_power", 25)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("channelgroupaddperm", {
cgid: 10,
permsid: "i_channel_subscribe_power",
permvalue: 25,
permskip: 0,
permnegated: 0
})
})
it("should verify parameters of #channelGroupAddPerm() with permid", async () => {
await teamspeak.channelGroupAddPerm(10, 11, 25)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("channelgroupaddperm", {
cgid: 10,
permid: 11,
permvalue: 25,
permskip: 0,
permnegated: 0
})
})
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(0, 10, 0, "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(0, 10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("privilegekeyadd", {
tokentype: 0,
tokenid1: 10,
tokenid2: 0,
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).toHaveBeenCalledWith("privilegekeydelete", { token: "asdf" })
})
it("should verify parameters of #privilegeKeyUse()", async () => {
await teamspeak.privilegeKeyUse("asdf")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("privilegekeyuse", { token: "asdf" })
})
it("should verify parameters of #messageList()", async () => {
await teamspeak.messageList()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("messagelist")
})
it("should verify parameters of #messageAdd()", async () => {
await teamspeak.messageAdd("uniqueidentifier=", "title", "content")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("messageadd", {
cluid: "uniqueidentifier=",
subject: "title",
message: "content"
})
})
it("should verify parameters of #messageDel()", async () => {
await teamspeak.messageDel(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("messagedel", { msgid: 10 })
})
it("should verify parameters of #messageGet()", async () => {
await teamspeak.messageGet(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("messageget", { msgid: 10 })
})
it("should verify parameters of #messageUpdate()", async () => {
await teamspeak.messageUpdate(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("messageupdateflag", { msgid: 10, flag: 1 })
})
it("should verify parameters of #complainList()", async () => {
await teamspeak.complainList(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("complainlist", { cldbid: 10 })
})
it("should verify parameters of #complainAdd()", async () => {
await teamspeak.complainAdd(10, "message")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("complainadd", { cldbid: 10, message: "message" })
})
describe("#complainDel()", () => {
it("should deletes all complaints for the given dbid", async () => {
await teamspeak.complainDel(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("complaindelall", { tcldbid: 10 })
})
it("should delete only a single complaint", async () => {
await teamspeak.complainDel(10, 15)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("complaindel", { tcldbid: 10, fcldbid: 15 })
})
})
it("should verify parameters of #banList()", async () => {
await teamspeak.banList(5, 10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("banlist", { start: 5, duration: 10 })
})
it("should verify parameters of #ban()", async () => {
const rule = { ip: "127.0.0.1", uid: "something=", name: "FooBar", mytsid: "empty", banreason: "spam", time: 60 }
await teamspeak.ban({ ...rule })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("banadd", { ...rule })
})
it("should verify parameters of #banClient()", async () => {
const rule = { clid: 1337, mytsid: "empty", banreason: "spam", time: 60 }
await teamspeak.banClient({ ...rule })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("banclient", { ...rule })
})
describe("#banDel()", () => {
it("should remove a single ban", async () => {
await teamspeak.banDel(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("bandel", { banid: 10 })
})
it("should remove all bans", async () => {
await teamspeak.banDel()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("bandelall")
})
})
it("should verify parameters of #logView()", async () => {
await teamspeak.logView()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("logview", { lines: 1000, reverse: 0, instance: 0, begin_pos: 0 })
})
it("should verify parameters of #logAdd()", async () => {
await teamspeak.logAdd(LogLevel.DEBUG, "custom message")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("logadd", { loglevel: 3, logmsg: "custom message" })
})
it("should verify parameters of #gm()", async () => {
await teamspeak.gm("Global Message")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("gm", { msg: "Global Message" })
})
it("should verify parameters of #clientDBInfo()", async () => {
await teamspeak.clientDBInfo(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientdbinfo", { cldbid: 10 })
})
it("should verify parameters of #clientDBFind()", async () => {
await teamspeak.clientDBFind("John Doe")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientdbfind", { pattern: "John Doe" }, [null])
})
it("should verify parameters of #clientDBFind() with an uid", async () => {
await teamspeak.clientDBFind("foobar=", true)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientdbfind", { pattern: "foobar=" }, ["-uid"])
})
it("should verify parameters of #clientDBEdit()", async () => {
await teamspeak.clientDBEdit(10, { client_description: "foo" })
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientdbedit", { cldbid: 10, client_description: "foo" })
})
it("should verify parameters of #clientDBDelete()", async () => {
await teamspeak.clientDBDelete(10)
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("clientdbdelete", { cldbid: 10 })
})
it("should verify parameters of #serverList()", async () => {
await teamspeak.serverList()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("serverlist", ["-uid", "-all"])
})
it("should verify parameters of #channelGroupList()", async () => {
await teamspeak.channelGroupList()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("channelgrouplist")
})
it("should verify parameters of #serverGroupList()", async () => {
await teamspeak.serverGroupList()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toHaveBeenCalledWith("servergrouplist")
})
it("should verify parameters of #channelFind()", async () => {
await teamspeak.channelFind("foo")
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toBeCalledWith("channelfind", { pattern: "foo" })
})
it("should verify parameters of #channelList()", async () => {
await teamspeak.channelList()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toBeCalledWith(
"channellist",
["-topic", "-flags", "-voice", "-limits", "-icon", "-secondsempty"]
)
})
it("should verify parameters of #clientList()", async () => {
await teamspeak.clientList()
expect(mockExecute).toHaveBeenCalledTimes(1)
expect(mockExecute).toBeCalledWith(
"clientlist",
["-uid", "-away", "-voice", "-ti