Notes/spec/search/parens.spec.ts

27 lines
780 B
TypeScript
Raw Normal View History

2024-07-24 20:31:26 +03:00
import handleParens from "../../src/services/search/services/handle_parens.js";
import { TokenStructure } from "../../src/services/search/services/types.js";
2020-05-19 00:00:35 +02:00
describe("Parens handler", () => {
2020-05-20 00:03:33 +02:00
it("handles parens", () => {
2020-07-19 23:19:45 +02:00
const input = ["(", "hello", ")", "and", "(", "(", "pick", "one", ")", "and", "another", ")"]
.map(token => ({token}));
const actual: TokenStructure = [
[
{token: "hello"}
],
{token: "and"},
[
2020-05-19 00:00:35 +02:00
[
{token: "pick"},
{token: "one"}
2020-05-19 00:00:35 +02:00
],
2020-07-19 23:19:45 +02:00
{token: "and"},
{token: "another"}
]
];
expect(handleParens(input)).toEqual(actual);
2020-05-19 00:00:35 +02:00
});
});