2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 06:16:07 +00:00

src/telegram: reset state of global regexp (#326)

References:

  * BR: https://github.com/yagop/node-telegram-bot-api/issues/325
  * BR-by: @Sirius-A
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/326
  * PR-by: @Sirius-A
This commit is contained in:
Fabio Zuber
2017-05-13 09:53:21 +02:00
committed by Gocho Mugo
parent 3d4d10f9b3
commit 9f3107b5ab
2 changed files with 12 additions and 0 deletions

View File

@@ -975,6 +975,16 @@ describe('TelegramBot', function telegramSuite() {
message: { text: '/onText ECHO ALOHA' },
});
});
it('should reset the global regex state with each message', function test(done) {
const regexp = /\/onText (.+)/g;
botWebHook.onText(regexp, () => {
assert.equal(regexp.lastIndex, 0);
return done();
});
utils.sendWebHookMessage(webHookPort2, TOKEN, {
message: { text: '/onText ECHO ALOHA' },
});
});
});
describe.skip('#onReplyToMessage', function onReplyToMessageSuite() {});