2
0
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:
GochoMugo
2017-12-08 19:25:56 +03:00
parent b968e893d3
commit 04e8b892aa
4 changed files with 32 additions and 5 deletions

View File

@@ -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();
}));
});
});
});