|
|
|
|
@ -812,8 +812,113 @@ describe('TelegramBot', function telegramSuite() { |
|
|
|
|
|
|
|
|
|
describe.skip('#unbanChatMember', function unbanChatMemberSuite() {}); |
|
|
|
|
|
|
|
|
|
describe.skip('#restrictChatMember', function restrictChatMemberSuite() {}); |
|
|
|
|
|
|
|
|
|
describe.skip('#promoteChatMember', function promoteChatMemberSuite() {}); |
|
|
|
|
|
|
|
|
|
describe.skip('#answerCallbackQuery', function answerCallbackQuerySuite() {}); |
|
|
|
|
|
|
|
|
|
describe('#exportChatInviteLink', function exportChatInviteLinkSuite() { |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'exportChatInviteLink', this); |
|
|
|
|
}); |
|
|
|
|
it('should export the group invite link', function test() { |
|
|
|
|
return bot.exportChatInviteLink(GROUPID).then(resp => { |
|
|
|
|
assert(resp.match(/^https:\/\/t\.me\/joinchat\/.+$/i), 'is a telegram invite link'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#setChatPhoto', function setChatPhotoSuite() { |
|
|
|
|
this.timeout(timeout); |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'setChatPhoto', this); |
|
|
|
|
}); |
|
|
|
|
it('should set a chat photo from file', function test() { |
|
|
|
|
const photo = `${__dirname}/data/chat_photo.png`; |
|
|
|
|
return bot.setChatPhoto(GROUPID, photo).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should set a chat photo from fs.readStream', function test() { |
|
|
|
|
const photo = fs.createReadStream(`${__dirname}/data/chat_photo.png`); |
|
|
|
|
return bot.setChatPhoto(GROUPID, photo).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should set a chat photo from request Stream', function test() { |
|
|
|
|
const photo = request(`${staticUrl}/chat_photo.png`); |
|
|
|
|
return bot.setChatPhoto(GROUPID, photo).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should set a chat photo from a Buffer', function test() { |
|
|
|
|
const photo = fs.readFileSync(`${__dirname}/data/chat_photo.png`); |
|
|
|
|
return bot.setChatPhoto(GROUPID, photo).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#deleteChatPhoto', function deleteChatPhotoSuite() { |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'deleteChatPhoto', this); |
|
|
|
|
}); |
|
|
|
|
it('should delete the chat photo', function test() { |
|
|
|
|
return bot.deleteChatPhoto(GROUPID).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#setChatTitle', function setChatTitleSuite() { |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'setChatTitle', this); |
|
|
|
|
}); |
|
|
|
|
it('should set the chat title', function test() { |
|
|
|
|
return bot.setChatTitle(GROUPID, 'ntba test group').then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#setChatDescription', function setChatDescriptionSuite() { |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'setChatDescription', this); |
|
|
|
|
}); |
|
|
|
|
it('should set the chat description', function test() { |
|
|
|
|
return bot.setChatDescription(GROUPID, 'node-telegram-bot-api test group').then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#pinChatMessage', function pinChatMessageSuite() { |
|
|
|
|
let messageId; |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'pinChatMessage', this); |
|
|
|
|
return bot.sendMessage(GROUPID, 'To be pinned').then(resp => { |
|
|
|
|
messageId = resp.message_id; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
it('should pin chat message', function test() { |
|
|
|
|
return bot.pinChatMessage(GROUPID, messageId).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#unpinChatMessage', function unpinChatMessageSuite() { |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'unpinChatMessage', this); |
|
|
|
|
}); |
|
|
|
|
it('should unpin chat message', function test() { |
|
|
|
|
return bot.unpinChatMessage(GROUPID).then(resp => { |
|
|
|
|
assert.equal(resp, true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('#editMessageText', function editMessageTextSuite() { |
|
|
|
|
before(function before() { |
|
|
|
|
utils.handleRatelimit(bot, 'sendMessage', this); |
|
|
|
|
|