Notes/spec/search/parens.spec.js

25 lines
721 B
JavaScript
Raw Permalink Normal View History

const handleParens = require('../../src/services/search/services/handle_parens');
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}));
2020-07-21 00:01:07 +02:00
expect(handleParens(input))
2020-05-19 00:00:35 +02:00
.toEqual([
[
2020-07-19 23:19:45 +02:00
{token: "hello"}
2020-05-19 00:00:35 +02:00
],
2020-07-19 23:19:45 +02:00
{token: "and"},
2020-05-19 00:00:35 +02:00
[
[
2020-07-19 23:19:45 +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"}
2020-05-19 00:00:35 +02:00
]
]);
});
});