2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

Add SendDocument Test

Add SendDocument Test
This commit is contained in:
Riddler 2015-07-07 13:54:57 +05:30
parent c2d4ec145a
commit 16b9d2b695

View File

@ -203,3 +203,45 @@ describe('Telegram', function () {
});
describe('#sendDocument', function () {
var documentId;
it('should send a document from file', function (done) {
var bot = new Telegram(TOKEN);
var document = __dirname+'/bot.gif';
bot.sendDocument(USERID, document).then(function (resp) {
resp.should.be.an.instanceOf(Object);
documentId = resp.document.file_id;
done();
});
});
it('should send a photo from id', function (done) {
var bot = new Telegram(TOKEN);
// Send the same photo as before
var document = documentId;
bot.sendPhoto(USERID, document).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
it('should send a photo from fs.readStream', function (done) {
var bot = new Telegram(TOKEN);
var document = fs.createReadStream(__dirname+'/bot.gif');
bot.sendDocument(USERID, document).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
it('should send a document from request Stream', function (done) {
var bot = new Telegram(TOKEN);
var document = request('https://telegram.org/img/t_logo.png');
bot.sendDocument(USERID, document).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
});