Skip to content

Commit 8cac580

Browse files
author
fletcherist
committed
fix: bug with commands (array)
1 parent 31c8328 commit 8cac580

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

examples/guessNumber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Videotutorial: https://youtu.be/exPnIFMa1H8
33
*/
44

5-
const Alice = require('yandex-dialogs-sdk')
5+
const Alice = require('../dist/index')
66
const alice = new Alice()
77

88
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min

src/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default class Commands implements CommandsInterface {
3030

3131
get _strings() {
3232
return this.commands.filter((command) =>
33-
command.type === TYPE_FIGURE || command.type === TYPE_STRING)
33+
[TYPE_FIGURE, TYPE_STRING, TYPE_ARRAY].includes(command.type),
34+
)
3435
}
3536
get _figures() {
3637
return this.commands.filter((command) => command.type === TYPE_FIGURE)

src/tests/alice.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ test('matching with array', async (done) => {
1414
const alice = new Alice()
1515

1616
alice.command(['привет', 'как дела'], (ctx) => done())
17+
alice.any((ctx) => ctx)
1718
alice.handleRequest(generateRequest('Привет, как дела?'))
1819
})
1920

2021
test('matching with regexp', async (done) => {
2122
const alice = new Alice()
2223

2324
alice.command(/[а-яё]+/i, (ctx) => done())
25+
alice.any((ctx) => ctx)
2426
alice.handleRequest(generateRequest('Привет как дела'))
2527
})
2628

@@ -29,6 +31,7 @@ test('priority check, strings over regexps', async (done) => {
2931

3032
alice.command(/[а-яё]+/i, (ctx) => new Error('Error has occured'))
3133
alice.command('привет', (ctx) => done())
34+
alice.any((ctx) => ctx)
3235
alice.handleRequest(generateRequest('Привет как дела'))
3336
})
3437

0 commit comments

Comments
 (0)