From 16b9d2b69599216924e42594b00462219bdd27f1 Mon Sep 17 00:00:00 2001 From: Riddler Date: Tue, 7 Jul 2015 13:54:57 +0530 Subject: [PATCH] Add SendDocument Test Add SendDocument Test --- test/index.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/index.js b/test/index.js index 29946bb..84b3af5 100644 --- a/test/index.js +++ b/test/index.js @@ -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(); + }); + }); + });