This commit is contained in:
Leifer Mendez
2022-10-29 19:11:44 +02:00
parent 3e2869b54a
commit eccbe59a1a
6 changed files with 64 additions and 39 deletions

View File

@@ -6,11 +6,11 @@
**addKeyword** recibe `string | string[]`
> `sensitivy` false _default_
> `sensitive` false _default_
- [x] addKeyword
- [x] addAnswer
- [ ] addKeyword: Opciones
- [x] addKeyword: Opciones
- [ ] addAnswer: Opciones
- [ ] Retornar SQL
- [ ] Retornar JSON
@@ -72,21 +72,21 @@ await inout
})
await inout
.addKeyword('Modelo C', { sensitivy: false })
.addKeyword('Modelo C', { sensitive: false })
.addAnswer('100USD', { media: 'http//:...' })
await inout
.addKeyword('hola!', { sensitivy: false })
.addKeyword('hola!', { sensitive: false })
.addAnswer('Bievenido Escribe *productos*')
await inout
.addKeyword('productos', { sensitivy: false })
.addKeyword('productos', { sensitive: false })
.addAnswer('Esto son los mas vendidos')
.addAnswer('*PC1* Precio 10USD', { media: 'https://....' })
.addAnswer('*PC2* Precio 10USD', { media: 'https://....' })
await inout
.addKeyword('PC1', { sensitivy: false })
.addKeyword('PC1', { sensitive: false })
.addAnswer('Bievenido Escribe *productos*')
const answerOne = await inout.addAnswer({

View File

@@ -1,32 +1,2 @@
const { addKeyword, addAnswer } = require('./methods')
module.exports = { addKeyword, addAnswer }
// const test = async () => {
// const cxtA = addKeyword('hola')
// console.log({ cxtA: cxtA.ctx.keyword, ref: cxtA.ref })
// const cxtB = addAnswer(cxtA)('b')
// console.log({ cxtB: cxtB.ctx.message, ref: cxtB.ref })
// const cxtC = addAnswer(cxtB)('c')
// console.log({ cxtC: cxtC.ctx.keyword, ref: cxtC.ref })
// }
// const test1 = async () => {
// const cxtAB = addKeyword('hola').addAnswer('b').addAnswer('c')
// console.log({
// keyword: cxtAB.ctx.keyword,
// anwser: cxtAB.ctx.message,
// })
// }
// const test2 = async () => {
// const cxtABB = addKeyword('hola')
// .addAnswer('Bienvenido a tu tienda 🥲')
// .addAnswer('escribe *catalogo* o *ofertas*')
// console.log({
// pregunta: cxtABB.ctx.keyword,
// ultimasrespuesta: cxtABB.ctx.message,
// })
// }
// test2().then()

View File

@@ -8,16 +8,30 @@ const { addAnswer } = require('./addAnswer')
/**
*
* @param {*} message `string | string[]`
* @param {*} options {sensitivy:boolean} defaulta false
* @param {*} options {sensitive:boolean} default
*/
const addKeyword = (message, options) => {
/**
* Esta funcion deberia parsear y validar las opciones
* del keyword
* @returns
*/
const parseOptions = () => {
const defaultProperties = {
sensitive: options?.sensitive ?? true,
}
return defaultProperties
}
const ctxAddKeyword = () => {
const ref = generateRef()
const options = parseOptions()
/**
* Se guarda en db
*/
return { ref, keyword: message }
return { ref, keyword: message, options }
}
const ctx = ctxAddKeyword()

View File

@@ -12,6 +12,15 @@ test('Debere probar las propeidades', () => {
assert.is(MAIN_CTX.ctx.keyword, ARRANGE.keyword)
})
test('Debere probar las propeidades array', () => {
const ARRANGE = {
keyword: ['hola!', 'ole'],
}
const MAIN_CTX = addKeyword(ARRANGE.keyword)
assert.is(MAIN_CTX.ctx.keyword, ARRANGE.keyword)
})
test('Debere probar el paso de contexto', () => {
const ARRANGE = {
keyword: 'hola!',
@@ -38,4 +47,10 @@ test('Debere probar la anidación', () => {
assert.is(MAIN_CTX.ctx.answer, ARRANGE.answer_B)
})
test('Debere probar las poptions', () => {
const MAIN_CTX = addKeyword('etc', { sensitive: false })
assert.is(MAIN_CTX.ctx.options.sensitive, false)
})
test.run()