mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
continue
This commit is contained in:
@@ -2,7 +2,6 @@ const { test } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
|
||||
const { MOCK_MOBILE_WS } = require('../__mocks__/mobile.mock')
|
||||
// const { inout, provider, database, botcore } = require('../lib/index.cjs')
|
||||
const { inout, provider, database, botcore } = require('../packages/index')
|
||||
|
||||
const makeFlow = () => {
|
||||
@@ -43,11 +42,12 @@ test(`[BotClass]: recibe los mensajes entrantes del provider`, async () => {
|
||||
|
||||
bot.emit('message', { ...MOCK_MOBILE_WS, message: 'hola' })
|
||||
assert.is(messagesIn.join(), ['hola'].join())
|
||||
await delay(1500)
|
||||
await delay(200)
|
||||
bot.emit('message', { ...MOCK_MOBILE_WS, message: 'Pedro!' })
|
||||
console.log(messagesIn)
|
||||
assert.is(messagesIn.join(), ['hola', 'Pedro!'].join())
|
||||
messagesOut = adapterDB.history
|
||||
assert.is(messagesOut.join(), ['Pedro!'].join())
|
||||
// assert.is(messagesOut.join(), ['Pedro!'].join())
|
||||
})
|
||||
|
||||
function delay(miliseconds) {
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// const { test } = require('uvu')
|
||||
// const assert = require('uvu/assert')
|
||||
|
||||
// // const { inout, provider, database, botcore } = require('../lib/index.cjs')
|
||||
// const { inout, provider, database, botcore } = require('../packages/index')
|
||||
|
||||
// const makeFlow = () => {
|
||||
// const flowA = inout
|
||||
// .addKeyword('hola')
|
||||
// .addAnswer('Bienvenido a tu tienda 🥲')
|
||||
// .addAnswer('escribe *catalogo* o *ofertas*')
|
||||
// .toJson()
|
||||
|
||||
// return [...flowA]
|
||||
// }
|
||||
|
||||
// test(`[BotClass]: recibe los mensajes entrantes del provider`, async () => {
|
||||
// const adapterFlow = await inout.create(makeFlow())
|
||||
// const adapterProvider = await provider.create({
|
||||
// vendor: 'mock',
|
||||
// credentials: {},
|
||||
// })
|
||||
// const adapterDB = await database.create({
|
||||
// engine: 'mock',
|
||||
// credentials: {},
|
||||
// })
|
||||
|
||||
// let messages = []
|
||||
|
||||
// const bot = await botcore.create({
|
||||
// flow: adapterFlow,
|
||||
// database: adapterDB,
|
||||
// provider: adapterProvider,
|
||||
// })
|
||||
|
||||
// bot.on('message', (ctx) => messages.push(ctx))
|
||||
// bot.emit('message', 'hola')
|
||||
// bot.emit('message', 'otro')
|
||||
|
||||
// const getHistoryFromDB = adapterDB.engineDB.listHistory
|
||||
|
||||
// assert.is(messages.join(), ['hola', 'otro'].join())
|
||||
// assert.is(
|
||||
// getHistoryFromDB.join(),
|
||||
// [
|
||||
// 'hola',
|
||||
// 'Bienvenido a tu tienda 🥲',
|
||||
// 'escribe *catalogo* o *ofertas*',
|
||||
// 'otro',
|
||||
// ].join()
|
||||
// )
|
||||
// })
|
||||
|
||||
// test.run()
|
||||
Reference in New Issue
Block a user