add test.js for yarn testfunc

This commit is contained in:
JernKunpittaya
2023-06-08 19:43:29 -04:00
parent efc24e440c
commit d4f347658b
4 changed files with 1116 additions and 36 deletions

3
.babelrc Normal file
View File

@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}

View File

@@ -20,7 +20,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"testback": "mocha --require @babel/register 'src/test.js'"
},
"eslintConfig": {
"extends": [
@@ -39,5 +40,11 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/preset-env": "^7.22.5",
"@babel/preset-react": "^7.22.5",
"@babel/register": "^7.22.5",
"mocha": "^10.2.0"
}
}

17
src/test.js Normal file
View File

@@ -0,0 +1,17 @@
import { simplifyGraph, findSubstrings } from "./gen_dfa";
function test() {
const text =
"adsfasd DKI: v=12/; d=22; a=//121; d=1; bh=xUqTs2T2FPGCOB52 sdflj";
const regex = "DKI: (([vad]=([12/]+); )+)bh";
const simp_graph = simplifyGraph(regex);
const matched_dfa = findSubstrings(simp_graph, text);
for (const subs of matched_dfa[1]) {
var matched = text.slice(subs[0], subs[1] + 1);
console.log("matched: ", matched);
}
}
describe("test backend", function () {
it("should print correctly", function () {
test();
});
});

1123
yarn.lock

File diff suppressed because it is too large Load Diff