mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-31 06:16:07 +00:00
src/telegram: Emit 'info' on stream from TelegramBot#getFileStream()
This commit is contained in:
@@ -1160,7 +1160,7 @@ describe('TelegramBot', function telegramSuite() {
|
||||
return bot.getFileLink(FILE_ID)
|
||||
.then(fileURI => {
|
||||
assert.ok(is.string(fileURI));
|
||||
assert.ok(/https?:\/\/.*\/file\/bot.*\/.*/.test(fileURI));
|
||||
assert.ok(utils.isTelegramFileURI(fileURI));
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1174,10 +1174,14 @@ describe('TelegramBot', function telegramSuite() {
|
||||
const fileStream = bot.getFileStream(FILE_ID);
|
||||
assert.ok(fileStream instanceof stream.Readable);
|
||||
assert.equal(fileStream.path, FILE_ID);
|
||||
fileStream.pipe(concat(function readFile(buffer) {
|
||||
buffer.equals(fs.readFileSync(FILE_PATH)); // sync :(
|
||||
return done();
|
||||
}));
|
||||
fileStream.on('info', (info) => {
|
||||
assert.ok(info);
|
||||
assert.ok(utils.isTelegramFileURI(info.uri), `${info.uri} is not a file URI`);
|
||||
fileStream.pipe(concat(function readFile(buffer) {
|
||||
buffer.equals(fs.readFileSync(FILE_PATH)); // sync :(
|
||||
return done();
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user