mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 13:27:44 +00:00
[v4.0] Add tests and add minor improvement
Follow up update to #625 - Tests for both methods (sendAnimation, editMediaMessage) have been added. editMediaMessage is nested under sendAnimation, hence both tests are technically under a single block. - Add an improvement/minor fix to the editMediaMessage method, where we now stringify the first parameter (media) object interally within the library. This allows the lib user to simply pass an object as the 1st param without stringifying it.
This commit is contained in:
parent
11a6b221e9
commit
6a7c088a63
@ -1228,7 +1228,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
* @see https://core.telegram.org/bots/api#editmessagemedia
|
* @see https://core.telegram.org/bots/api#editmessagemedia
|
||||||
*/
|
*/
|
||||||
editMessageMedia(media, form = {}) {
|
editMessageMedia(media, form = {}) {
|
||||||
form.media = media;
|
form.media = stringify(media);
|
||||||
return this._request('editMessageMedia', { form });
|
return this._request('editMessageMedia', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,4 +1436,28 @@ describe('TelegramBot', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#sendAnimation', function sendAnimationSuite() {
|
||||||
|
before(function before() {
|
||||||
|
utils.handleRatelimit(bot, 'sendAnimation', this);
|
||||||
|
});
|
||||||
|
it('should send a gif as an animation', function test() {
|
||||||
|
return bot.sendAnimation(USERID, `${__dirname}/data/photo.gif`).then(resp => {
|
||||||
|
assert.ok(is.object(resp));
|
||||||
|
assert.ok(is.object(resp.document));
|
||||||
|
|
||||||
|
describe('#editMessageMedia', function editMessageMediaSuite() {
|
||||||
|
before(function before() {
|
||||||
|
utils.handleRatelimit(bot, 'editMessageMedia', this);
|
||||||
|
});
|
||||||
|
it('should edit a media message', function test() {
|
||||||
|
return bot.editMessageMedia({ type: 'animation', media: resp.document.file_id, caption: 'media message edited'}, { chat_id: resp.chat.id, message_id: resp.message_id}).then(editedResp => {
|
||||||
|
assert.ok(is.object(editedResp));
|
||||||
|
assert.ok(is.string(editedResp.caption));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}); // End Telegram
|
}); // End Telegram
|
||||||
|
Loading…
x
Reference in New Issue
Block a user