downloadFile test

experimental
Yago 10 years ago
parent c5f97ce524
commit 610a989e69
  1. 29
      test/index.js

@ -470,33 +470,28 @@ 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 download a file', function (done) {
it('should send a photo from file', function (done) {
var bot = new Telegram(TOKEN); var bot = new Telegram(TOKEN);
var photo = __dirname + '/bot.gif'; var photo = __dirname + '/bot.gif';
// Send a file to get the ID
bot.sendPhoto(USERID, photo).then(function (resp) { bot.sendPhoto(USERID, photo).then(function (resp) {
resp.should.be.an.instanceOf(Object); resp.should.be.an.instanceOf(Object);
fileId = resp.photo[0].file_id; var fileId = resp.photo[0].file_id;
done();
});
});
it('should download a file', function (done) { bot.downloadFile(fileId, downloadPath)
.then(function (filePath) {
var bot = new Telegram(TOKEN); filePath.should.be.an.instanceOf(String);
fs.existsSync(filePath).should.be.true();
bot.downloadFile(fileId, downloadPath).then(function (filePath) { fs.unlinkSync(filePath); // Delete file after test
filePath.should.be.an.instanceOf(String); done();
fs.existsSync(filePath).should.be.true(); });
fs.unlinkSync(filePath); // Delete file after test
done();
}); });
}); });
}); });
it('should call `onText` callback on match', function (done) { it('should call `onText` callback on match', function (done) {

Loading…
Cancel
Save