@ -17,13 +17,14 @@ const USERID = process.env.TEST_USER_ID || 777000;
describe ( 'Telegram' , function telegramSuite ( ) {
describe ( 'Telegram' , function telegramSuite ( ) {
describe ( '#setWebHook' , function setWebHookSuite ( ) {
describe ( '#setWebHook' , function setWebHookSuite ( ) {
it ( 'should set a webHook' , function test ( ) {
it ( 'should set a webHook' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
// Google IP ¯\_(ツ)_/¯
// Google IP ¯\_(ツ)_/¯
return bot
return bot
. setWebHook ( '216.58.210.174' )
. setWebHook ( '216.58.210.174' )
. then ( resp => {
. then ( resp => {
assert . equal ( resp , true ) ;
assert . equal ( resp , true ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -150,13 +151,14 @@ describe('Telegram', function telegramSuite() {
} ) ;
} ) ;
describe ( '#forwardMessage' , function forwardMessageSuite ( ) {
describe ( '#forwardMessage' , function forwardMessageSuite ( ) {
it ( 'should forward a message' , function test ( ) {
it ( 'should forward a message' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
return bot . sendMessage ( USERID , 'test' ) . then ( resp => {
return bot . sendMessage ( USERID , 'test' ) . then ( resp => {
const messageId = resp . message _id ;
const messageId = resp . message _id ;
return bot . forwardMessage ( USERID , USERID , messageId )
return bot . forwardMessage ( USERID , USERID , messageId )
. then ( forwarded => {
. then ( forwarded => {
assert . ok ( is . object ( forwarded ) ) ;
assert . ok ( is . object ( forwarded ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -164,208 +166,290 @@ describe('Telegram', function telegramSuite() {
describe ( '#sendPhoto' , function sendPhotoSuite ( ) {
describe ( '#sendPhoto' , function sendPhotoSuite ( ) {
let photoId ;
let photoId ;
it ( 'should send a photo from file' , function test ( ) {
it ( 'should send a photo from file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
photoId = resp . photo [ 0 ] . file _id ;
photoId = resp . photo [ 0 ] . file _id ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a photo from id' , function test ( ) {
it ( 'should send a photo from id' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
// Send the same photo as before
// Send the same photo as before
const photo = photoId ;
const photo = photoId ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a photo from fs.readStream' , function test ( ) {
it ( 'should send a photo from fs.readStream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = fs . createReadStream ( ` ${ _ _dirname } /bot.gif ` ) ;
const photo = fs . createReadStream ( ` ${ _ _dirname } /bot.gif ` ) ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a photo from request Stream' , function test ( ) {
it ( 'should send a photo from request Stream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = request ( 'https://telegram.org/img/t_logo.png' ) ;
const photo = request ( 'https://telegram.org/img/t_logo.png' ) ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a photo from a Buffer' , function test ( ) {
it ( 'should send a photo from a Buffer' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = fs . readFileSync ( ` ${ _ _dirname } /bot.gif ` ) ;
const photo = fs . readFileSync ( ` ${ _ _dirname } /bot.gif ` ) ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#sendChatAction' , function sendChatActionSuite ( ) {
describe ( '#sendChatAction' , function sendChatActionSuite ( ) {
it ( 'should send a chat action' , function test ( ) {
it ( 'should send a chat action' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const action = 'typing' ;
const action = 'typing' ;
return bot . sendChatAction ( USERID , action ) . then ( resp => {
return bot . sendChatAction ( USERID , action ) . then ( resp => {
assert . equal ( resp , true ) ;
assert . equal ( resp , true ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
describe ( '#editMessageText' , function editMessageTextSuite ( ) {
it ( 'should edit a message sent by the bot' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
return bot . sendMessage ( USERID , 'test' ) . then ( resp => {
assert . equal ( resp . text , 'test' ) ;
const opts = {
chat _id : USERID ,
message _id : resp . message _id
} ;
return bot . editMessageText ( 'edit test' , opts ) . then ( msg => {
assert . equal ( msg . text , 'edit test' ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#editMessageCaption' , function editMessageCaptionSuite ( ) {
it ( 'should edit a caption sent by the bot' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
const options = { caption : 'test caption' } ;
return bot . sendPhoto ( USERID , photo , options ) . then ( resp => {
assert . equal ( resp . caption , 'test caption' ) ;
const opts = {
chat _id : USERID ,
message _id : resp . message _id
} ;
return bot . editMessageCaption ( 'new test caption' , opts ) . then ( msg => {
assert . equal ( msg . caption , 'new test caption' ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#editMessageReplyMarkup' , function editMessageReplyMarkupSuite ( ) {
it ( 'should edit previously-set reply markup' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
return bot . sendMessage ( USERID , 'test' ) . then ( resp => {
const replyMarkup = JSON . stringify ( {
inline _keyboard : [ [ {
text : 'Test button' ,
callback _data : 'test'
} ] ]
} ) ;
const opts = {
chat _id : USERID ,
message _id : resp . message _id
} ;
return bot . editMessageReplyMarkup ( replyMarkup , opts ) . then ( msg => {
// Keyboard markup is not returned, do a simple object check
assert . ok ( is . object ( msg ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#sendAudio' , function sendAudioSuite ( ) {
describe ( '#sendAudio' , function sendAudioSuite ( ) {
it ( 'should send an OGG audio' , function test ( ) {
it ( 'should send an OGG audio' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const audio = request ( 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg' ) ;
const audio = request ( 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg' ) ;
return bot . sendAudio ( USERID , audio ) . then ( resp => {
return bot . sendAudio ( USERID , audio ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#sendDocument' , function sendDocumentSuite ( ) {
describe ( '#sendDocument' , function sendDocumentSuite ( ) {
let documentId ;
let documentId ;
it ( 'should send a document from file' , function test ( ) {
it ( 'should send a document from file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const document = ` ${ _ _dirname } /bot.gif ` ;
const document = ` ${ _ _dirname } /bot.gif ` ;
return bot . sendDocument ( USERID , document ) . then ( resp => {
return bot . sendDocument ( USERID , document ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
documentId = resp . document . file _id ;
documentId = resp . document . file _id ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a document from id' , function test ( ) {
it ( 'should send a document from id' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
// Send the same photo as before
// Send the same photo as before
const document = documentId ;
const document = documentId ;
return bot . sendDocument ( USERID , document ) . then ( resp => {
return bot . sendDocument ( USERID , document ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a document from fs.readStream' , function test ( ) {
it ( 'should send a document from fs.readStream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const document = fs . createReadStream ( ` ${ _ _dirname } /bot.gif ` ) ;
const document = fs . createReadStream ( ` ${ _ _dirname } /bot.gif ` ) ;
return bot . sendDocument ( USERID , document ) . then ( resp => {
return bot . sendDocument ( USERID , document ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a document from request Stream' , function test ( ) {
it ( 'should send a document from request Stream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const document = request ( 'https://telegram.org/img/t_logo.png' ) ;
const document = request ( 'https://telegram.org/img/t_logo.png' ) ;
return bot . sendDocument ( USERID , document ) . then ( resp => {
return bot . sendDocument ( USERID , document ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a document from a Buffer' , function test ( ) {
it ( 'should send a document from a Buffer' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const document = fs . readFileSync ( ` ${ _ _dirname } /bot.gif ` ) ;
const document = fs . readFileSync ( ` ${ _ _dirname } /bot.gif ` ) ;
return bot . sendDocument ( USERID , document ) . then ( resp => {
return bot . sendDocument ( USERID , document ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#sendSticker' , function sendStickerSuite ( ) {
describe ( '#sendSticker' , function sendStickerSuite ( ) {
let stickerId ;
let stickerId ;
it ( 'should send a sticker from file' , function test ( ) {
it ( 'should send a sticker from file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const sticker = ` ${ _ _dirname } /sticker.webp ` ;
const sticker = ` ${ _ _dirname } /sticker.webp ` ;
return bot . sendSticker ( USERID , sticker ) . then ( resp => {
return bot . sendSticker ( USERID , sticker ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
stickerId = resp . sticker . file _id ;
stickerId = resp . sticker . file _id ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a sticker from id' , function test ( ) {
it ( 'should send a sticker from id' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
// Send the same photo as before
// Send the same photo as before
return bot . sendSticker ( USERID , stickerId ) . then ( resp => {
return bot . sendSticker ( USERID , stickerId ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a sticker from fs.readStream' , function test ( ) {
it ( 'should send a sticker from fs.readStream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const sticker = fs . createReadStream ( ` ${ _ _dirname } /sticker.webp ` ) ;
const sticker = fs . createReadStream ( ` ${ _ _dirname } /sticker.webp ` ) ;
return bot . sendSticker ( USERID , sticker ) . then ( resp => {
return bot . sendSticker ( USERID , sticker ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a sticker from request Stream' , function test ( ) {
it ( 'should send a sticker from request Stream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const sticker = request ( 'https://www.gstatic.com/webp/gallery3/1_webp_ll.webp' ) ;
const sticker = request ( 'https://www.gstatic.com/webp/gallery3/1_webp_ll.webp' ) ;
return bot . sendSticker ( USERID , sticker ) . then ( resp => {
return bot . sendSticker ( USERID , sticker ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a sticker from a Buffer' , function test ( ) {
it ( 'should send a sticker from a Buffer' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const sticker = fs . readFileSync ( ` ${ _ _dirname } /sticker.webp ` ) ;
const sticker = fs . readFileSync ( ` ${ _ _dirname } /sticker.webp ` ) ;
return bot . sendDocument ( USERID , sticker ) . then ( resp => {
return bot . sendDocument ( USERID , sticker ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#sendVideo' , function sendVideoSuite ( ) {
describe ( '#sendVideo' , function sendVideoSuite ( ) {
let videoId ;
let videoId ;
it ( 'should send a video from file' , function test ( ) {
it ( 'should send a video from file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const video = ` ${ _ _dirname } /video.mp4 ` ;
const video = ` ${ _ _dirname } /video.mp4 ` ;
return bot . sendVideo ( USERID , video ) . then ( resp => {
return bot . sendVideo ( USERID , video ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
videoId = resp . video . file _id ;
videoId = resp . video . file _id ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a video from id' , function test ( ) {
it ( 'should send a video from id' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
// Send the same photo as before
// Send the same photo as before
return bot . sendVideo ( USERID , videoId ) . then ( resp => {
return bot . sendVideo ( USERID , videoId ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a video from fs.readStream' , function test ( ) {
it ( 'should send a video from fs.readStream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const video = fs . createReadStream ( ` ${ _ _dirname } /video.mp4 ` ) ;
const video = fs . createReadStream ( ` ${ _ _dirname } /video.mp4 ` ) ;
return bot . sendVideo ( USERID , video ) . then ( resp => {
return bot . sendVideo ( USERID , video ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a video from request Stream' , function test ( ) {
it ( 'should send a video from request Stream' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const sticker = request ( 'http://techslides.com/demos/sample-videos/small.mp4' ) ;
const sticker = request ( 'http://techslides.com/demos/sample-videos/small.mp4' ) ;
return bot . sendVideo ( USERID , sticker ) . then ( resp => {
return bot . sendVideo ( USERID , sticker ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should send a video from a Buffer' , function test ( ) {
it ( 'should send a video from a Buffer' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const video = fs . readFileSync ( ` ${ _ _dirname } /video.mp4 ` ) ;
const video = fs . readFileSync ( ` ${ _ _dirname } /video.mp4 ` ) ;
return bot . sendVideo ( USERID , video ) . then ( resp => {
return bot . sendVideo ( USERID , video ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( '#sendVoice' , function sendVoiceSuite ( ) {
describe ( '#sendVoice' , function sendVoiceSuite ( ) {
it ( 'should send an OGG audio as voice' , function test ( ) {
it ( 'should send an OGG audio as voice' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const voice = request ( 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg' ) ;
const voice = request ( 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg' ) ;
return bot . sendVoice ( USERID , voice ) . then ( resp => {
return bot . sendVoice ( USERID , voice ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -399,16 +483,17 @@ describe('Telegram', function telegramSuite() {
let fileId ;
let fileId ;
// To get a file we have to send any file first
// To get a file we have to send any file first
it ( 'should send a photo from file' , function test ( ) {
it ( 'should send a photo from file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
fileId = resp . photo [ 0 ] . file _id ;
fileId = resp . photo [ 0 ] . file _id ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should get a file' , function test ( ) {
it ( 'should get a file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
return bot
return bot
@ -416,6 +501,7 @@ describe('Telegram', function telegramSuite() {
. then ( resp => {
. then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . string ( resp . file _path ) ) ;
assert . ok ( is . string ( resp . file _path ) ) ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -424,16 +510,17 @@ describe('Telegram', function telegramSuite() {
let fileId ;
let fileId ;
// To get a file we have to send any file first
// To get a file we have to send any file first
it ( 'should send a photo from file' , function test ( ) {
it ( 'should send a photo from file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
return bot . sendPhoto ( USERID , photo ) . then ( resp => {
assert . ok ( is . object ( resp ) ) ;
assert . ok ( is . object ( resp ) ) ;
fileId = resp . photo [ 0 ] . file _id ;
fileId = resp . photo [ 0 ] . file _id ;
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
it ( 'should get a file link' , function test ( ) {
it ( 'should get a file link' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
return bot
return bot
@ -441,6 +528,7 @@ describe('Telegram', function telegramSuite() {
. then ( fileURI => {
. then ( fileURI => {
assert . ok ( is . string ( fileURI ) ) ;
assert . ok ( is . string ( fileURI ) ) ;
assert . equal ( fileURI . indexOf ( 'https' ) , 0 ) ;
assert . equal ( fileURI . indexOf ( 'https' ) , 0 ) ;
done ( ) ;
// TODO: validate URL with some library or regexp
// TODO: validate URL with some library or regexp
} ) ;
} ) ;
} ) ;
} ) ;
@ -449,7 +537,7 @@ describe('Telegram', function telegramSuite() {
describe ( '#downloadFile' , function downloadFileSuite ( ) {
describe ( '#downloadFile' , function downloadFileSuite ( ) {
const downloadPath = _ _dirname ;
const downloadPath = _ _dirname ;
it ( 'should download a file' , function test ( ) {
it ( 'should download a file' , function test ( done ) {
const bot = new Telegram ( TOKEN ) ;
const bot = new Telegram ( TOKEN ) ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
const photo = ` ${ _ _dirname } /bot.gif ` ;
@ -464,6 +552,7 @@ describe('Telegram', function telegramSuite() {
assert . ok ( is . string ( filePath ) ) ;
assert . ok ( is . string ( filePath ) ) ;
assert . ok ( fs . existsSync ( filePath ) ) ;
assert . ok ( fs . existsSync ( filePath ) ) ;
fs . unlinkSync ( filePath ) ; // Delete file after test
fs . unlinkSync ( filePath ) ; // Delete file after test
done ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;