-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathsetup-tests.js
63 lines (58 loc) · 1.2 KB
/
setup-tests.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
56
57
58
59
60
61
62
63
/*
* A Mock of the node-telegram-bot-api object
*/
const botMock = {
sendMessage: jest.fn(),
sendChatAction: jest.fn(),
/**
* Bot sample response by type
* @param {} input="/start"
* @param {} type="command"
* TODO : Refactor this function to something cleaner
*/
message: (input = "/start", type = "command") => {
const message = {
message_id: 105,
from: {
id: 12345,
is_bot: false,
first_name: "Lawrence",
username: "kodjunkie",
language_code: "en",
},
chat: {
id: 12345,
first_name: "Lawrence",
username: "kodjunkie",
type: "private",
},
date: 1583018575,
text: input,
};
// Command "/anything"
if (type === "command") {
message.entities = [{ offset: 0, length: 6, type: "bot_command" }];
}
// inline_keyboard
if (type === "text_mention") {
message.entities = [
{
offset: 6,
length: 9,
type: "text_mention",
user: {
id: 12345,
is_bot: false,
first_name: "Lawrence",
username: "kodjunkie",
language_code: "en",
},
},
{ offset: 32, length: 7, type: "bold" },
{ offset: 43, length: 3, type: "bold" },
];
}
return message;
},
};
global.bot = botMock;