-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
55 lines (47 loc) · 1.83 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const DisStat = require("./index.js")
test("missing apikey", () => {
expect(() => new DisStat()).toThrow(TypeError)
})
test("missing botId", () => {
expect(() => new DisStat("DS-jest")).toThrow(TypeError)
})
test("getBot", async () => {
const disstat = new DisStat("DS-jest", "jest")
const bot = await disstat.getBot("685166801394335819")
expect(Object.keys(bot)).toContain("username")
})
test("getBot non-public without api key", async () => {
const disstat = new DisStat("DS-jest", "jest")
const bot = await disstat.getBot("1015335483112431778")
expect(Object.keys(bot)).toContain("message")
})
test("getBot non-public with api key", async () => {
const disstat = new DisStat("DS-JEST-esWa3aPpL0L27m", "jest")
const bot = await disstat.getBot("1015335483112431778")
expect(Object.keys(bot)).toContain("username")
})
test("postData with invalid api key", async () => {
const disstat = new DisStat("DS-jest", "1015335483112431778")
const data = await disstat.postData({guilds: 1})
expect(Object.keys(data)).toContain("message")
})
test("postData with valid api key", async () => {
const disstat = new DisStat("DS-JEST-esWa3aPpL0L27m", "1015335483112431778")
expect(await disstat.postData({guilds: 1})).toBeUndefined()
})
test("postCommand empty", async () => {
const disstat = new DisStat("DS-jest", "jest")
expect(disstat.postCommand()).toBeInstanceOf(TypeError)
})
test("postCommand with content", async () => {
const disstat = new DisStat("DS-jest", "jest")
expect(disstat.postCommand("jest")).toBeUndefined()
})
test("postCustom empty", async () => {
const disstat = new DisStat("DS-jest", "jest")
expect(disstat.postCustom()).toBeInstanceOf(TypeError)
})
test("postCustom with all four args", async () => {
const disstat = new DisStat("DS-jest", "jest")
expect(disstat.postCustom("jest", "jest", "jest", "jest")).toBeUndefined()
})