|
|
@@ -1,3 +1,5 @@
|
|
|
+import { CURSOR_MARKER } from "../services/ghost/ghostConstants.js"
|
|
|
+
|
|
|
export interface TestCase {
|
|
|
name: string
|
|
|
category: string
|
|
|
@@ -13,7 +15,7 @@ export const testCases: TestCase[] = [
|
|
|
name: "closing-brace",
|
|
|
category: "Basic Syntax",
|
|
|
input: `function test() {
|
|
|
- console.log('hello')<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ console.log('hello')${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 23 },
|
|
|
expectedPatterns: ["}", "\\n}"],
|
|
|
description: "Should complete closing brace for function",
|
|
|
@@ -21,7 +23,7 @@ export const testCases: TestCase[] = [
|
|
|
{
|
|
|
name: "semicolon",
|
|
|
category: "Basic Syntax",
|
|
|
- input: `const x = 42<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `const x = 42${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 12 },
|
|
|
expectedPatterns: [";"],
|
|
|
description: "Should add semicolon after variable declaration",
|
|
|
@@ -29,7 +31,7 @@ export const testCases: TestCase[] = [
|
|
|
{
|
|
|
name: "closing-bracket",
|
|
|
category: "Basic Syntax",
|
|
|
- input: `const arr = [1, 2, 3<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `const arr = [1, 2, 3${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 20 },
|
|
|
expectedPatterns: ["]"],
|
|
|
description: "Should complete closing bracket for array",
|
|
|
@@ -37,7 +39,7 @@ export const testCases: TestCase[] = [
|
|
|
{
|
|
|
name: "closing-parenthesis",
|
|
|
category: "Basic Syntax",
|
|
|
- input: `console.log('test'<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `console.log('test'${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 18 },
|
|
|
expectedPatterns: ["\\)"],
|
|
|
description: "Should complete closing parenthesis for function call",
|
|
|
@@ -48,7 +50,7 @@ export const testCases: TestCase[] = [
|
|
|
name: "property-access",
|
|
|
category: "Property Access",
|
|
|
input: `const obj = { name: 'test', value: 42 };
|
|
|
-obj.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+obj.${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 4 },
|
|
|
expectedPatterns: ["name", "value"],
|
|
|
description: "Should suggest object properties",
|
|
|
@@ -57,7 +59,7 @@ obj.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "array-method",
|
|
|
category: "Method Access",
|
|
|
input: `const arr = [1, 2, 3];
|
|
|
-arr.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+arr.${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 4 },
|
|
|
expectedPatterns: ["map", "filter", "forEach", "push", "pop", "length"],
|
|
|
description: "Should suggest array methods",
|
|
|
@@ -66,7 +68,7 @@ arr.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "string-method",
|
|
|
category: "Method Access",
|
|
|
input: `const str = 'hello world';
|
|
|
-str.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+str.${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 4 },
|
|
|
expectedPatterns: ["substring", "charAt", "indexOf", "length", "toUpperCase", "toLowerCase"],
|
|
|
description: "Should suggest string methods",
|
|
|
@@ -76,7 +78,7 @@ str.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "function-body",
|
|
|
category: "Function Declaration",
|
|
|
- input: `function calculateSum(a, b) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `function calculateSum(a, b) ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 29 },
|
|
|
expectedPatterns: ["{", "{\\n", "{\\s*\\n\\s*return a \\+ b"],
|
|
|
description: "Should complete function body opening",
|
|
|
@@ -84,7 +86,7 @@ str.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "arrow-function",
|
|
|
category: "Function Declaration",
|
|
|
- input: `const add = (a, b) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `const add = (a, b) ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 20 },
|
|
|
expectedPatterns: ["=>", "=> {", "=> a \\+ b"],
|
|
|
description: "Should complete arrow function syntax",
|
|
|
@@ -93,7 +95,7 @@ str.<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "function-call-args",
|
|
|
category: "Function Call",
|
|
|
input: `function greet(name) { return 'Hello ' + name; }
|
|
|
-greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+greet(${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 6 },
|
|
|
expectedPatterns: ["\\)", "'", '"'],
|
|
|
description: "Should suggest function call argument completion",
|
|
|
@@ -103,7 +105,7 @@ greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "variable-assignment",
|
|
|
category: "Variable Assignment",
|
|
|
- input: `const userName = <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `const userName = ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 17 },
|
|
|
expectedPatterns: ["'", '"', "null", "undefined"],
|
|
|
description: "Should suggest common variable assignments",
|
|
|
@@ -111,7 +113,7 @@ greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "array-declaration",
|
|
|
category: "Variable Assignment",
|
|
|
- input: `const numbers = <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `const numbers = ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 16 },
|
|
|
expectedPatterns: ["\\[", "\\[]"],
|
|
|
description: "Should suggest array initialization",
|
|
|
@@ -119,7 +121,7 @@ greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "object-declaration",
|
|
|
category: "Variable Assignment",
|
|
|
- input: `const config = <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `const config = ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 15 },
|
|
|
expectedPatterns: ["{", "{}", "{\\s*\\n"],
|
|
|
description: "Should suggest object initialization",
|
|
|
@@ -129,7 +131,7 @@ greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "import-from",
|
|
|
category: "Import Statement",
|
|
|
- input: `import { useState } from <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `import { useState } from ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 25 },
|
|
|
expectedPatterns: ["'", '"', "'react'", '"react"'],
|
|
|
description: "Should complete import module name",
|
|
|
@@ -137,7 +139,7 @@ greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "import-curly-brace",
|
|
|
category: "Import Statement",
|
|
|
- input: `import <<<AUTOCOMPLETE_HERE>>> from 'react'`,
|
|
|
+ input: `import ${CURSOR_MARKER} from 'react'`,
|
|
|
cursorPosition: { line: 0, character: 7 },
|
|
|
expectedPatterns: ["{", "React", "\\* as"],
|
|
|
description: "Should suggest import syntax options",
|
|
|
@@ -148,7 +150,7 @@ greet(<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "if-statement",
|
|
|
category: "Control Flow",
|
|
|
input: `const x = 10;
|
|
|
-if (x > 5) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+if (x > 5) ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 11 },
|
|
|
expectedPatterns: ["{", "{\\n", "{\\s*\\n\\s*console.log"],
|
|
|
description: "Should complete if statement body",
|
|
|
@@ -156,7 +158,7 @@ if (x > 5) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
{
|
|
|
name: "for-loop",
|
|
|
category: "Control Flow",
|
|
|
- input: `for (let i = 0; i < 10; i++) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ input: `for (let i = 0; i < 10; i++) ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 0, character: 30 },
|
|
|
expectedPatterns: ["{", "{\\n", "{\\s*\\n\\s*console.log"],
|
|
|
description: "Should complete for loop body",
|
|
|
@@ -165,7 +167,7 @@ if (x > 5) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "return-statement",
|
|
|
category: "Control Flow",
|
|
|
input: `function getValue() {
|
|
|
- return <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ return ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 9 },
|
|
|
expectedPatterns: ["null", "undefined", "true", "false", "{", "\\["],
|
|
|
description: "Should suggest return value completions",
|
|
|
@@ -176,8 +178,8 @@ if (x > 5) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "chained-methods",
|
|
|
category: "Complex",
|
|
|
input: `const result = [1, 2, 3]
|
|
|
- .map(x => x * 2)
|
|
|
- .<<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ .map(x => x * 2)
|
|
|
+ .${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 2, character: 3 },
|
|
|
expectedPatterns: ["filter", "reduce", "forEach", "map"],
|
|
|
description: "Should suggest chained array methods",
|
|
|
@@ -186,9 +188,9 @@ if (x > 5) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "nested-object",
|
|
|
category: "Complex",
|
|
|
input: `const config = {
|
|
|
- server: {
|
|
|
- port: 3000,
|
|
|
- <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ server: {
|
|
|
+ port: 3000,
|
|
|
+ ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 3, character: 4 },
|
|
|
expectedPatterns: ["host:", "hostname:", "}"],
|
|
|
description: "Should suggest nested object properties",
|
|
|
@@ -197,7 +199,7 @@ if (x > 5) <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
name: "async-await",
|
|
|
category: "Complex",
|
|
|
input: `async function fetchData() {
|
|
|
- const response = await <<<AUTOCOMPLETE_HERE>>>`,
|
|
|
+ const response = await ${CURSOR_MARKER}`,
|
|
|
cursorPosition: { line: 1, character: 25 },
|
|
|
expectedPatterns: ["fetch", "axios", "Promise"],
|
|
|
description: "Should suggest async operations",
|