test: a lot test

This commit is contained in:
Leifer Mendez
2023-02-09 15:09:52 +01:00
parent af803415e3
commit dda59fa93b
16 changed files with 530 additions and 513 deletions

View File

@@ -25,16 +25,8 @@ class FlowClass {
let refSymbol = null
overFlow = overFlow ?? this.flowSerialize
const customRegex = (str = null) => {
if (typeof str !== 'string') return
const instanceRegex = new RegExp(str)
return instanceRegex.test(str)
}
/** Retornar expresion regular para buscar coincidencia */
const mapSensitive = (str, mapOptions = { sensitive: false, regex: false }) => {
if (mapOptions.regex) return customRegex(str)
if (mapOptions.regex) return new RegExp(str)
const regexSensitive = mapOptions.sensitive ? 'g' : 'i'
if (Array.isArray(str)) {
return new RegExp(str.join('|'), regexSensitive)
@@ -43,10 +35,7 @@ class FlowClass {
}
const findIn = (keyOrWord, symbol = false, flow = overFlow) => {
const sensitive = refSymbol?.options?.sensitive || false
const regex = refSymbol?.options?.regex || false
capture = refSymbol?.options?.capture || false
if (capture) return messages
if (symbol) {
@@ -55,6 +44,8 @@ class FlowClass {
if (refSymbol?.ref) findIn(refSymbol.ref, true)
} else {
refSymbol = flow.find((c) => {
const sensitive = c?.options?.sensitive || false
const regex = c?.options?.regex || false
return mapSensitive(c.keyword, { sensitive, regex }).test(keyOrWord)
})
if (refSymbol?.ref) findIn(refSymbol.ref, true)