Elffuss BraidHub

kikocis/continue public

80eede9a6f83 · 1.4 KiBRawPermalink
1import { describe, expect, test } from "vitest";
2import { closeTag, splitAtCodeblocksAndNewLines } from "./systemToolUtils";
3
4describe("closeTag", () => {
5 const testCases = [
6 {
7 input: "<div>",
8 expectedOutput: "</div>",
9 },
10 {
11 input: "<p>",
12 expectedOutput: "</p>",
13 },
14 // Add more test cases as needed
15 ];
16
17 testCases.forEach((testCase) => {
18 test(`closes tag "${testCase.input}" to "</${testCase.input.slice(1)}"`, () => {
19 const result = closeTag(testCase.input);
20 expect(result).toEqual(testCase.expectedOutput);
21 });
22 });
23});
24
25describe("splitAtCodeblocks", () => {
26 test("doesn't split plain text without codeblocks", () => {
27 expect(splitAtCodeblocksAndNewLines("hello world")).toEqual([
28 "hello world",
29 ]);
30 });
31
32 test("splits at codeblocks", () => {
33 expect(splitAtCodeblocksAndNewLines("```<one>middle```<two>")).toEqual([
34 "```",
35 "<one>middle",
36 "```",
37 "<two>",
38 ]);
39 });
40
41 test("splits at new lines", () => {
42 expect(splitAtCodeblocksAndNewLines("hello\nhoware\n you\n")).toEqual([
43 "hello",
44 "\n",
45 "howare",
46 "\n",
47 " you",
48 "\n",
49 ]);
50 });
51
52 test("splits at both codeblocks and new lines", () => {
53 expect(splitAtCodeblocksAndNewLines("hello```\nho```ware\n you\n")).toEqual(
54 ["hello", "```", "\n", "ho", "```", "ware", "\n", " you", "\n"],
55 );
56 });
57});