mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-30 13:58:27 +00:00
Run test for TelegramBot#_formatSendData() on supported Node.js versions
Bug: The test for `TelegramBot#_formatSendData()` is only applicable on newer versions of Node.js (v6+) that support passing a Buffer representation of the path to `fs.createReadStream()`. Fix: If the runtime does NOT supports passing the Buffer argument, do NOT run the test on it. This is safe since we are sure that `fs.ReadStream.path` will never be a Buffer on the runtime being tested.
This commit is contained in:
@@ -203,7 +203,14 @@ describe('Telegram', function telegramSuite() {
|
|||||||
describe('#_formatSendData', function _formatSendData() {
|
describe('#_formatSendData', function _formatSendData() {
|
||||||
it('should handle buffer path from fs.readStream', function test() {
|
it('should handle buffer path from fs.readStream', function test() {
|
||||||
const bot = new Telegram(TOKEN);
|
const bot = new Telegram(TOKEN);
|
||||||
const photo = fs.createReadStream(Buffer.from(`${__dirname}/bot.gif`));
|
let photo;
|
||||||
|
try {
|
||||||
|
photo = fs.createReadStream(Buffer.from(`${__dirname}/bot.gif`));
|
||||||
|
} catch(ex) {
|
||||||
|
// Older Node.js versions do not support passing a Buffer
|
||||||
|
// representation of the path to fs.createReadStream()
|
||||||
|
if (ex instanceof TypeError) return;
|
||||||
|
}
|
||||||
return bot.sendPhoto(USERID, photo).then(resp => {
|
return bot.sendPhoto(USERID, photo).then(resp => {
|
||||||
assert.ok(is.object(resp));
|
assert.ok(is.object(resp));
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user