11import { describe , it , expect , beforeEach , vi } from "vitest"
22import { MockWorkspace } from "./MockWorkspace"
33import * as vscode from "vscode"
4- import { GhostStreamingParser } from "../classic-auto-complete/GhostStreamingParser"
4+ import { parseGhostResponse } from "../classic-auto-complete/GhostStreamingParser"
55import { GhostSuggestionContext } from "../types"
66
77vi . mock ( "vscode" , ( ) => ( {
@@ -65,11 +65,9 @@ vi.mock("vscode", () => ({
6565
6666describe ( "GhostProvider" , ( ) => {
6767 let mockWorkspace : MockWorkspace
68- let streamingParser : GhostStreamingParser
6968
7069 beforeEach ( ( ) => {
7170 vi . clearAllMocks ( )
72- streamingParser = new GhostStreamingParser ( )
7371 mockWorkspace = new MockWorkspace ( )
7472
7573 vi . mocked ( vscode . workspace . openTextDocument ) . mockImplementation ( async ( uri : any ) => {
@@ -107,8 +105,7 @@ describe("GhostProvider", () => {
107105 const { context } = await setupTestDocument ( "empty.js" , initialContent )
108106
109107 // Test empty response
110- streamingParser . initialize ( context )
111- const result = streamingParser . parseResponse ( "" , "" , "" )
108+ const result = parseGhostResponse ( "" , "" , "" , context . document , context . range )
112109 expect ( result . suggestions . hasSuggestions ( ) ) . toBe ( false )
113110 } )
114111
@@ -118,8 +115,7 @@ describe("GhostProvider", () => {
118115
119116 // Test invalid XML format
120117 const invalidXML = "This is not a valid XML format"
121- streamingParser . initialize ( context )
122- const result = streamingParser . parseResponse ( invalidXML , "" , "" )
118+ const result = parseGhostResponse ( invalidXML , "" , "" , context . document , context . range )
123119 expect ( result . suggestions . hasSuggestions ( ) ) . toBe ( false )
124120 } )
125121
@@ -137,8 +133,7 @@ describe("GhostProvider", () => {
137133 const xmlResponse = `<change><search><![CDATA[console.log('test');]]></search><replace><![CDATA[// Added comment
138134console.log('test');]]></replace></change>`
139135
140- streamingParser . initialize ( context )
141- const result = streamingParser . parseResponse ( xmlResponse , "" , "" )
136+ const result = parseGhostResponse ( xmlResponse , "" , "" , context . document , context . range )
142137 // Should work with the XML format
143138 expect ( result . suggestions . hasSuggestions ( ) ) . toBe ( true )
144139 } )
0 commit comments