server-esm: Fix wonderful token type mismatch

This commit is contained in:
Elian Doran
2024-07-18 22:18:10 +03:00
parent 20c729e62b
commit 0c87fab550
5 changed files with 23 additions and 19 deletions

View File

@@ -1,24 +1,26 @@
const handleParens = require('../../src/services/search/services/handle_parens');
import handleParens from "../../src/services/search/services/handle_parens";
import { TokenStructure } from "../../src/services/search/services/types";
describe("Parens handler", () => {
it("handles parens", () => {
const input = ["(", "hello", ")", "and", "(", "(", "pick", "one", ")", "and", "another", ")"]
.map(token => ({token}));
expect(handleParens(input))
.toEqual([
const actual: TokenStructure = [
[
{token: "hello"}
],
{token: "and"},
[
[
{token: "hello"}
{token: "pick"},
{token: "one"}
],
{token: "and"},
[
[
{token: "pick"},
{token: "one"}
],
{token: "and"},
{token: "another"}
]
]);
{token: "another"}
]
];
expect(handleParens(input)).toEqual(actual);
});
});