Elffuss BraidHub

kikocis/continue public

a367fdbffe58 · 1.8 KiBRawPermalink
1import { describe, expect, it } from "vitest";
2import {
3 processTestCase,
4 type CompletionTestCase,
5} from "./completionTestUtils";
6
7describe("processTestCase utility", () => {
8 it("processes simple console.log completion", () => {
9 const testCase: CompletionTestCase = {
10 original: "console.log(|cur||till|)",
11 completion: '"foo,", bar',
12 };
13
14 expect(processTestCase(testCase)).toEqual({
15 input: {
16 lastLineOfCompletionText: '"foo,", bar',
17 currentText: ")",
18 cursorPosition: "console.log(".length,
19 },
20 expectedResult: {
21 completionText: '"foo,", bar',
22 },
23 });
24 });
25
26 it("processes simple console.log completion with overwriting", () => {
27 const testCase: CompletionTestCase = {
28 original: "console.log(|cur|)|till|",
29 completion: '"foo,", bar);',
30 };
31
32 expect(processTestCase(testCase)).toEqual({
33 input: {
34 lastLineOfCompletionText: '"foo,", bar);',
35 currentText: ")",
36 cursorPosition: "console.log(".length,
37 },
38 expectedResult: {
39 completionText: '"foo,", bar);',
40 range: {
41 start: "console.log(".length,
42 end: "console.log()".length,
43 },
44 },
45 });
46 });
47
48 it("partially applying completion", () => {
49 const testCase: CompletionTestCase = {
50 original: '|cur||till|fetch("https://example.com");',
51 completion: 'await fetch("https://example.com");',
52 appliedCompletion: "await ",
53 };
54
55 expect(processTestCase(testCase)).toEqual({
56 input: {
57 lastLineOfCompletionText: 'await fetch("https://example.com");',
58 currentText: 'fetch("https://example.com");',
59 cursorPosition: 0,
60 },
61 expectedResult: {
62 completionText: "await ",
63 },
64 });
65 });
66});