-
-
Notifications
You must be signed in to change notification settings - Fork 854
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #838 from codigoencasa/dev
chore: next version 0.1.32
- Loading branch information
Showing
39 changed files
with
1,917 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
const { suite } = require('uvu') | ||
const assert = require('uvu/assert') | ||
const { addKeyword, createBot, createFlow, EVENTS } = require('../packages/bot/index') | ||
const { setup, clear, delay } = require('../__mocks__/env') | ||
const { generateRefprovider } = require('../packages/provider/common/hash') | ||
|
||
const fakeHTTP = async (fakeData = []) => { | ||
await delay(50) | ||
const data = fakeData.map((u) => ({ body: `${u}` })) | ||
return Promise.resolve(data) | ||
} | ||
|
||
const suiteCase = suite('EVENTS:') | ||
|
||
suiteCase.before.each(setup) | ||
suiteCase.after.each(clear) | ||
|
||
suiteCase(`WELCOME`, async ({ database, provider }) => { | ||
const flow = addKeyword(EVENTS.WELCOME).addAnswer('Bievenido') | ||
|
||
createBot({ | ||
database, | ||
provider, | ||
flow: createFlow([flow]), | ||
}) | ||
|
||
await provider.delaySendMessage(0, 'message', { | ||
from: '000', | ||
body: 'hola', | ||
}) | ||
|
||
await delay(100) | ||
const getHistory = database.listHistory.map((i) => i.answer) | ||
|
||
assert.is('Bievenido', getHistory[0]) | ||
}) | ||
|
||
suiteCase(`MEDIA`, async ({ database, provider }) => { | ||
const flow = addKeyword(EVENTS.MEDIA).addAnswer('media recibido') | ||
|
||
createBot({ | ||
database, | ||
provider, | ||
flow: createFlow([flow]), | ||
}) | ||
|
||
await provider.delaySendMessage(0, 'message', { | ||
from: '000', | ||
body: generateRefprovider('_event_media_'), | ||
}) | ||
await delay(100) | ||
const getHistory = database.listHistory.map((i) => i.answer) | ||
|
||
assert.is('media recibido', getHistory[0]) | ||
}) | ||
|
||
suiteCase(`LOCATION`, async ({ database, provider }) => { | ||
const flow = addKeyword(EVENTS.LOCATION).addAnswer('location recibido') | ||
|
||
createBot({ | ||
database, | ||
provider, | ||
flow: createFlow([flow]), | ||
}) | ||
|
||
await provider.delaySendMessage(0, 'message', { | ||
from: '000', | ||
body: generateRefprovider('_event_location_'), | ||
}) | ||
await delay(100) | ||
const getHistory = database.listHistory.map((i) => i.answer) | ||
|
||
assert.is('location recibido', getHistory[0]) | ||
}) | ||
|
||
suiteCase(`DOCUMENT`, async ({ database, provider }) => { | ||
const flow = addKeyword(EVENTS.DOCUMENT).addAnswer('document recibido') | ||
|
||
createBot({ | ||
database, | ||
provider, | ||
flow: createFlow([flow]), | ||
}) | ||
|
||
await provider.delaySendMessage(0, 'message', { | ||
from: '000', | ||
body: generateRefprovider('_event_document_'), | ||
}) | ||
await delay(100) | ||
const getHistory = database.listHistory.map((i) => i.answer) | ||
|
||
assert.is('document recibido', getHistory[0]) | ||
}) | ||
|
||
suiteCase(`VOICE_NOTE`, async ({ database, provider }) => { | ||
const flow = addKeyword(EVENTS.VOICE_NOTE).addAnswer('voice recibido') | ||
|
||
createBot({ | ||
database, | ||
provider, | ||
flow: createFlow([flow]), | ||
}) | ||
|
||
await provider.delaySendMessage(0, 'message', { | ||
from: '000', | ||
body: generateRefprovider('_event_voice_note_'), | ||
}) | ||
await delay(100) | ||
const getHistory = database.listHistory.map((i) => i.answer) | ||
|
||
assert.is('voice recibido', getHistory[0]) | ||
}) | ||
|
||
suiteCase.run() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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: addAction (capture)') | ||
|
||
suiteCase.before.each(setup) | ||
suiteCase.after.each(clear) | ||
|
||
suiteCase(`Debe ejecutar accion con captura`, async ({ database, provider }) => { | ||
const flujoPrincipal = addKeyword(['hola']) | ||
.addAction(async (_, { flowDynamic }) => { | ||
return flowDynamic('Buenas! ¿Cual es tu nombre?') | ||
}) | ||
.addAction({ capture: true }, async (ctx, { flowDynamic, state }) => { | ||
state.update({ name: ctx.body }) | ||
return flowDynamic(`Gracias por tu nombre!: ${ctx.body}`) | ||
}) | ||
.addAnswer('Chao!') | ||
|
||
await createBot({ | ||
database, | ||
flow: createFlow([flujoPrincipal]), | ||
provider, | ||
}) | ||
|
||
await provider.delaySendMessage(0, 'message', { | ||
from: '000', | ||
body: 'hola', | ||
}) | ||
|
||
await provider.delaySendMessage(50, 'message', { | ||
from: '000', | ||
body: 'Leifer', | ||
}) | ||
|
||
await delay(1000) | ||
const getHistory = database.listHistory.map((i) => i.answer) | ||
assert.is('Buenas! ¿Cual es tu nombre?', getHistory[0]) | ||
assert.is('Gracias por tu nombre!: Leifer', getHistory[3]) | ||
assert.is('Chao!', getHistory[4]) | ||
assert.is(undefined, getHistory[5]) | ||
}) | ||
|
||
suiteCase.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.