mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
perf(adapter): 🐛 database json and lot tests
This commit is contained in:
31
__test__/0.0.1-case.test.js
Normal file
31
__test__/0.0.1-case.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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: Provider envia un location')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Responder a "CURRENT_LOCATION"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword('#CURRENT_LOCATION#').addAnswer('Gracias por tu location')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: '#CURRENT_LOCATION#',
|
||||
})
|
||||
|
||||
await delay(200)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Gracias por tu location', getHistory[0])
|
||||
assert.is(undefined, getHistory[1])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
Reference in New Issue
Block a user