2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 14:25:57 +00:00

[telegram] Return error on trying to use Polling, WebHook together

Feature:

  Polling and WebHook are mutually exclusive. Therefore, return an
  error whenever the user tries to start polling, and the instance has
  an open webhook, or user tries to open a webhook, and the instance
  is already polling.
This commit is contained in:
GochoMugo
2017-01-11 17:06:04 +03:00
parent 061d11a109
commit a9d6e93622
3 changed files with 22 additions and 0 deletions

View File

@@ -185,6 +185,12 @@ describe('TelegramBot', function telegramSuite() {
return utils.isPollingMockServer(pollingPort);
});
});
it('returns error if using webhook', function test() {
return botWebHook.startPolling().catch((err) => {
// TODO: check for error in a better way
assert.ok(err.message.indexOf('mutually exclusive') !== -1);
});
});
});
describe('#isPolling', function isPollingSuite() {
@@ -219,6 +225,12 @@ describe('TelegramBot', function telegramSuite() {
return utils.hasOpenWebHook(webHookPort);
});
});
it('returns error if using polling', function test() {
return botPolling.openWebHook().catch((err) => {
// TODO: check for error in a better way
assert.ok(err.message.indexOf('mutually exclusive') !== -1);
});
});
});
describe('#hasOpenWebHook', function hasOpenWebHookSuite() {