mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
ci
This commit is contained in:
25
.github/workflows/ci.yml
vendored
Normal file
25
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [monorepo]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm run build --if-present
|
||||
- run: npm run test:io
|
||||
@@ -6,7 +6,8 @@
|
||||
"scripts": {
|
||||
"cli": "node ./packages/cli/bin/cli.js",
|
||||
"cli:rollup": "rollup ./packages/cli/index.js --config ./packages/cli/rollup-cli.config.js",
|
||||
"io:rollup": "rollup ./packages/io/index.js --config ./packages/io/rollup-cli.config.js"
|
||||
"io:rollup": "rollup ./packages/io/index.js --config ./packages/io/rollup-cli.config.js",
|
||||
"test:io": "node ./node_modules/uvu/bin.js ./packages/io/tests"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/cli",
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user