mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-21 04:59:15 +00:00
pass test
This commit is contained in:
36
__tests__/basic-seller.e2e.test.js
Normal file
36
__tests__/basic-seller.e2e.test.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
const { test } = require('uvu')
|
||||||
|
const assert = require('uvu/assert')
|
||||||
|
|
||||||
|
const { inout, provider, database, botcore } = require('../packages/index')
|
||||||
|
|
||||||
|
const adapterDB = database.create({
|
||||||
|
engine: 'mock',
|
||||||
|
credentials: {},
|
||||||
|
})
|
||||||
|
|
||||||
|
const adapterProvider = provider.create({
|
||||||
|
vendor: 'mock',
|
||||||
|
credentials: {},
|
||||||
|
})
|
||||||
|
|
||||||
|
const makeFlow = () => {
|
||||||
|
const flowA = inout
|
||||||
|
.addKeyword('hola')
|
||||||
|
.addAnswer('Bienvenido a tu tienda 🥲')
|
||||||
|
.addAnswer('escribe *catalogo* o *ofertas*')
|
||||||
|
.toJson()
|
||||||
|
|
||||||
|
return [...flowA]
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapterFlow = inout.create(makeFlow())
|
||||||
|
|
||||||
|
test(`[Bot Vendedor]: recibe los mensajes entrantes del provider`, () => {
|
||||||
|
const bot = botcore.create({
|
||||||
|
flow: adapterFlow,
|
||||||
|
database: adapterDB,
|
||||||
|
provider: adapterProvider,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test.run()
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
const { test } = require('uvu')
|
|
||||||
const assert = require('uvu/assert')
|
|
||||||
const BotClass = require('../classes/bot.class')
|
|
||||||
|
|
||||||
class MockDB {
|
|
||||||
saveLog = () => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockProvider {
|
|
||||||
sendMessage = () => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockFlow {
|
|
||||||
find = () => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
test(`BotClass emit ping`, () => {
|
|
||||||
let messages = []
|
|
||||||
|
|
||||||
const botBasic = new BotClass(
|
|
||||||
new MockFlow(),
|
|
||||||
new MockDB(),
|
|
||||||
new MockProvider()
|
|
||||||
)
|
|
||||||
|
|
||||||
botBasic.on('message', (ctx) => messages.push(ctx))
|
|
||||||
botBasic.emit('message', 'ping')
|
|
||||||
|
|
||||||
assert.is(messages.join(''), 'ping')
|
|
||||||
})
|
|
||||||
|
|
||||||
test.run()
|
|
||||||
Reference in New Issue
Block a user