/
replyKeyboard.ts
64 lines (53 loc) · 1.46 KB
/
replyKeyboard.ts
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
64
import { ReplyKeyboard } from "..";
import * as assert from "assert";
import { describe, beforeEach } from "mocha";
/*
* Tests for Reply Keyboards
*/
describe("Reply Keyboards tests", () => {
// Some dummy data
let firstLoad = ["This is a field.", "This is another field"];
let secondLoad = ["Meh"];
let thirdLoad = ["Third load button"];
describe(".addRow(...keys)", () => {
let keyboard;
beforeEach("init keyboard", () => {
keyboard = new ReplyKeyboard();
});
it("Should add elements to a row and return the right number of rows via .extract() method", () => {
keyboard
.addRow(...firstLoad)
.addRow(...secondLoad);
assert.equal(keyboard.length, 2);
});
it("Should have a length property after .addRow(), which returns the amount of rows", () => {
assert.equal(keyboard.addRow(...thirdLoad).length, 1);
});
});
describe(".open()", () => {
let keyboard = new ReplyKeyboard();
keyboard
.addRow(...firstLoad)
.addRow(...secondLoad)
it("Should return the data structure for telegram", () => {
assert.deepStrictEqual(keyboard.open(), {
reply_markup: {
keyboard: [firstLoad, secondLoad]
}
});
});
});
describe(".close()", () => {
let keyboard = new ReplyKeyboard();
keyboard
.addRow(...firstLoad)
.addRow(...secondLoad)
it("Should return the telegram data structure", () => {
assert.deepStrictEqual(keyboard.close(), {
reply_markup: {
remove_keyboard: true,
}
});
});
});
});