Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcherist committed Jul 5, 2018
1 parent 09c04f8 commit 86e6d3a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/tests/alice.spec.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
const Alice = require('../alice')
const { generateRequest } = require('./testUtils')
import Alice from '../alice'
import { generateRequest } from './testUtils'

// Test for matching all command types

test('matching with string', async (done) => {
const alice = new Alice()

alice.command('Привет, как дела', (ctx) => done())
alice.handleRequestBody(generateRequest('Привет, как дела?'))
alice.handleRequest(generateRequest('Привет, как дела?'))
})

test('matching with array', async (done) => {
const alice = new Alice()

alice.command(['привет', 'как дела'], (ctx) => done())
alice.handleRequestBody(generateRequest('Привет, как дела?'))
alice.handleRequest(generateRequest('Привет, как дела?'))
})

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

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

test('priority check, strings over regexps', async (done) => {
const alice = new Alice()

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

test('listenining on port with callback', async (done) => {
Expand Down Expand Up @@ -61,7 +61,7 @@ test('ctx body', async (done) => {
})
done()
})
alice.handleRequestBody(
alice.handleRequest(
generateRequest('забронируй встречу в 7-холмов на 18:00'),
)
})

0 comments on commit 86e6d3a

Please sign in to comment.