2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 06:16:07 +00:00

Added getFileLink method to TelegramBot and moved generating of urls to separate method _buildURL

This commit is contained in:
Ivan Skorokhodov
2015-09-26 18:45:20 +03:00
parent e85f517e00
commit 6006ba4fd6
3 changed files with 86 additions and 5 deletions

View File

@@ -394,6 +394,32 @@ describe('Telegram', function () {
});
});
describe('#getFileLink', function () {
var fileId;
// To get a file we have to send any file first
it('should send a photo from file', function (done) {
var bot = new Telegram(TOKEN);
var photo = __dirname + '/bot.gif';
bot.sendPhoto(USERID, photo).then(function (resp) {
resp.should.be.an.instanceOf(Object);
fileId = resp.photo[0].file_id;
done();
});
});
it('should get a file link', function (done) {
var bot = new Telegram(TOKEN);
bot.getFileLink(fileId).then(function (fileURI) {
fileURI.should.be.an.instanceOf(String);
fileURI.should.startWith('https');
done(); // TODO: validate URL with some library or regexp
});
});
});
}); // End Telegram