@@ -7,6 +7,7 @@ import * as vscode from 'vscode'
77import * as sinon from 'sinon'
88import assert from 'assert'
99import * as path from 'path'
10+
1011import {
1112 FileSnapshot ,
1213 FileTrackerConfig ,
@@ -52,7 +53,7 @@ describe('PredictionTracker', function () {
5253 let mockDocument : vscode . TextDocument
5354
5455 beforeEach ( function ( ) {
55- filePath = path . join ( 'path' , 'to' , 'file.js' )
56+ filePath = testPath ( 'path' , 'to' , 'file.js' )
5657 previousContent = 'previous content'
5758 tracker = new PredictionTracker ( mockExtensionContext )
5859
@@ -127,8 +128,8 @@ describe('PredictionTracker', function () {
127128 }
128129 tracker = new PredictionTracker ( mockExtensionContext , customConfig )
129130
130- const file1 = path . join ( 'path' , 'to' , 'file1.js' )
131- const file2 = path . join ( 'path' , 'to' , 'file2.js' )
131+ const file1 = testPath ( 'path' , 'to' , 'file1.js' )
132+ const file2 = testPath ( 'path' , 'to' , 'file2.js' )
132133
133134 const initialTime = globals . clock . Date . now ( )
134135
@@ -161,12 +162,12 @@ describe('PredictionTracker', function () {
161162 } )
162163
163164 it ( 'should return empty array for non-existent file' , function ( ) {
164- const result = tracker . getFileSnapshots ( path . join ( 'non-existent' , 'file.js' ) )
165+ const result = tracker . getFileSnapshots ( testPath ( 'non-existent' , 'file.js' ) )
165166 assert . deepStrictEqual ( result , [ ] )
166167 } )
167168
168169 it ( 'should return snapshots for existing file' , async function ( ) {
169- const file = path . join ( 'path' , 'to' , 'file.js' )
170+ const file = testPath ( 'path' , 'to' , 'file.js' )
170171 const content = 'file content'
171172 const mockDocument = createMockDocument ( content , file )
172173 await tracker . processEdit ( mockDocument , content )
@@ -185,7 +186,7 @@ describe('PredictionTracker', function () {
185186
186187 beforeEach ( async function ( ) {
187188 tracker = new PredictionTracker ( mockExtensionContext )
188- file = path . join ( 'path' , 'to' , 'file.js' )
189+ file = testPath ( 'path' , 'to' , 'file.js' )
189190 snapshotContent = 'snapshot content'
190191 const mockDocument = createMockDocument ( snapshotContent , file )
191192 await tracker . processEdit ( mockDocument , snapshotContent )
@@ -208,7 +209,7 @@ describe('PredictionTracker', function () {
208209
209210 // Mock active editor, we only care about document
210211 mockEditor = {
211- document : createMockDocument ( 'current content' , path . join ( 'path' , 'to' , 'active.js' ) ) ,
212+ document : createMockDocument ( 'current content' , testPath ( 'path' , 'to' , 'active.js' ) ) ,
212213 selection : new vscode . Selection ( 0 , 0 , 0 , 0 ) ,
213214 selections : [ new vscode . Selection ( 0 , 0 , 0 , 0 ) ] ,
214215 options : { } ,
@@ -234,7 +235,7 @@ describe('PredictionTracker', function () {
234235 } )
235236
236237 it ( 'should generate and return supplemental contexts' , async function ( ) {
237- const filePath = path . join ( 'path' , 'to' , 'active.js' )
238+ const filePath = testPath ( 'path' , 'to' , 'active.js' )
238239 const initialTime = globals . clock . Date . now ( )
239240
240241 const mockDoc = createMockDocument ( 'old content 1' , filePath )
@@ -267,4 +268,9 @@ describe('PredictionTracker', function () {
267268 assert . strictEqual ( snapshotContents [ 1 ] . content , 'old content 2' )
268269 } )
269270 } )
271+
272+ function testPath ( ...segments : string [ ] ) : string {
273+ // Mock the path from vscode uri
274+ return path . sep + path . join ( ...segments )
275+ }
270276} )
0 commit comments