mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-19 20:19:15 +00:00
feat(provider): ⚡ support location �
This commit is contained in:
40
__test__/0.1.3-case.test.js
Normal file
40
__test__/0.1.3-case.test.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const { suite } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const suiteCase = suite('Flujo: capture')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Responder a "pregunta"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer(['Hola como estas?', '¿Cual es tu edad?'], { capture: true })
|
||||
.addAnswer('Gracias por tu respuesta')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: '90',
|
||||
})
|
||||
|
||||
await delay(20)
|
||||
|
||||
assert.is(['Hola como estas?', '¿Cual es tu edad?'].join('\n'), database.listHistory[0].answer)
|
||||
assert.is('90', database.listHistory[1].answer)
|
||||
assert.is('Gracias por tu respuesta', database.listHistory[2].answer)
|
||||
assert.is(undefined, database.listHistory[3])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
Reference in New Issue
Block a user