mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 05:17:41 +00:00
downloadFile test
This commit is contained in:
parent
c5f97ce524
commit
610a989e69
@ -470,27 +470,20 @@ describe('Telegram', function () {
|
|||||||
|
|
||||||
describe('#downloadFile', function () {
|
describe('#downloadFile', function () {
|
||||||
|
|
||||||
var fileId;
|
|
||||||
var downloadPath = __dirname;
|
var downloadPath = __dirname;
|
||||||
|
|
||||||
// To get a file we have to send some 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 download a file', function (done) {
|
it('should download a file', function (done) {
|
||||||
|
|
||||||
var bot = new Telegram(TOKEN);
|
var bot = new Telegram(TOKEN);
|
||||||
|
var photo = __dirname + '/bot.gif';
|
||||||
|
|
||||||
bot.downloadFile(fileId, downloadPath).then(function (filePath) {
|
// Send a file to get the ID
|
||||||
|
bot.sendPhoto(USERID, photo).then(function (resp) {
|
||||||
|
resp.should.be.an.instanceOf(Object);
|
||||||
|
var fileId = resp.photo[0].file_id;
|
||||||
|
|
||||||
|
bot.downloadFile(fileId, downloadPath)
|
||||||
|
.then(function (filePath) {
|
||||||
filePath.should.be.an.instanceOf(String);
|
filePath.should.be.an.instanceOf(String);
|
||||||
fs.existsSync(filePath).should.be.true();
|
fs.existsSync(filePath).should.be.true();
|
||||||
fs.unlinkSync(filePath); // Delete file after test
|
fs.unlinkSync(filePath); // Delete file after test
|
||||||
@ -499,6 +492,8 @@ describe('Telegram', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
it('should call `onText` callback on match', function (done) {
|
it('should call `onText` callback on match', function (done) {
|
||||||
var bot = new Telegram(TOKEN, {webHook: true});
|
var bot = new Telegram(TOKEN, {webHook: true});
|
||||||
bot.onText(/\/echo (.+)/, function (msg, match) {
|
bot.onText(/\/echo (.+)/, function (msg, match) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user