2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-09-05 08:45:44 +00:00

Add accompanying tests, minor fixes and updates for PR #158

This commit is contained in:
GochoMugo
2016-10-10 14:21:25 +03:00
parent 628aa5b2d9
commit f5af2bf588
4 changed files with 43 additions and 38 deletions

View File

@@ -4,5 +4,7 @@ Running the tests:
export TEST_TELEGRAM_TOKEN=<YOUR_BOT_TOKEN>
# User Id which you want to send the messages.
export TEST_USER_ID=<USER_ID>
# Group Id which to use in some of the tests, e.g. for TelegramBot#getChat()
export TEST_GROUP_ID=<GROUP_ID>
npm run test
```

View File

@@ -14,6 +14,7 @@ if (!TOKEN) {
// Telegram service if not User Id
const USERID = process.env.TEST_USER_ID || 777000;
const GROUPID = process.env.TEST_GROUP_ID || -1001075450562;
describe('Telegram', function telegramSuite() {
describe('#setWebHook', function setWebHookSuite() {
@@ -140,6 +141,34 @@ describe('Telegram', function telegramSuite() {
});
});
describe('#getChatAdministrators', function getChatAdministratorsSuite() {
it('should return an Array', function test() {
const bot = new Telegram(TOKEN);
return bot.getChatAdministrators(GROUPID).then(resp => {
assert.ok(Array.isArray(resp));
});
});
});
describe('#getChatMembersCount', function getChatMembersCountSuite() {
it('should return an Integer', function test() {
const bot = new Telegram(TOKEN);
return bot.getChatMembersCount(GROUPID).then(resp => {
assert.ok(Number.isInteger(resp));
});
});
});
describe('#getChatMember', function getChatMemberSuite() {
it('should return a ChatMember', function test() {
const bot = new Telegram(TOKEN);
return bot.getChatMember(GROUPID, USERID).then(resp => {
assert.ok(is.object(resp.user));
assert.ok(is.string(resp.status));
});
});
});
describe('#getUpdates', function getUpdatesSuite() {
it('should return an Array', function test() {
const bot = new Telegram(TOKEN);