Throw error if Unsupported Buffer file type. Test 'should send a video from a Buffer'

experimental
Yago 10 years ago
parent fd4cf4e353
commit f2153a7754
  1. 3
      src/telegram.js
  2. 11
      test/index.js

@ -239,6 +239,9 @@ TelegramBot.prototype._formatSendData = function (type, data) {
};
} else if (Buffer.isBuffer(data)) {
var filetype = fileType(data);
if (!filetype) {
throw new Error('Unsupported Buffer file type');
}
formData = {};
formData[type] = {
value: data,

@ -367,6 +367,17 @@ describe('Telegram', function () {
done();
});
});
/* Currently unsupported (https://github.com/sindresorhus/file-type/pull/44)
it('should send a video from a Buffer', function (done) {
var bot = new Telegram(TOKEN);
var video = fs.readFileSync(__dirname+'/video.mp4');
bot.sendVideo(USERID, video).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
*/
});
describe('#sendVoice', function () {

Loading…
Cancel
Save