@@ -14,20 +14,41 @@ describe('filePathToUri', () => {
1414 expect ( uri ) . toMatch ( / ^ f i l e / ) ;
1515 } ) ;
1616
17- it ( 'should handle windows path' , ( ) => {
18- const uri = filePathToUri ( 'C:\\ project\\ main.ts' ) ;
19- expect ( uri ) . toBe ( 'file:///c%3A%5Cproject%5Cmain .ts' ) ;
17+ it ( 'should handle network path' , ( ) => {
18+ const uri = filePathToUri ( '// project/ main.ts' ) ;
19+ expect ( uri ) . toBe ( 'file://project/main .ts' ) ;
2020 } ) ;
21+
22+ if ( process . platform === 'win32' ) {
23+ it ( 'should handle windows path' , ( ) => {
24+ const uri = filePathToUri ( 'C:\\project\\main.ts' ) ;
25+ expect ( uri ) . toBe ( 'file:///c%3A/project/main.ts' ) ;
26+ } ) ;
27+ }
2128} ) ;
2229
2330describe ( 'uriToFilePath' , ( ) => {
24- it ( 'should return valid fsPath for unix' , ( ) => {
25- const filePath = uriToFilePath ( 'file:///project/main.ts' ) ;
26- expect ( filePath ) . toBe ( '/project/main.ts' ) ;
27- } ) ;
31+ if ( process . platform === 'win32' ) {
32+ it ( 'should return valid fsPath for windows' , ( ) => {
33+ const filePath = uriToFilePath ( 'file:///c%3A/project/main.ts' ) ;
34+ expect ( filePath ) . toBe ( 'c:\\project\\main.ts' ) ;
35+ } ) ;
2836
29- it ( 'should return valid fsPath for windows' , ( ) => {
30- const filePath = uriToFilePath ( 'file:///c%3A%5Cproject%5Cmain.ts' ) ;
31- expect ( filePath ) . toBe ( 'c:\\project\\main.ts' ) ;
32- } ) ;
37+ it ( 'should return valid fsPath for network file uri' , ( ) => {
38+ const filePath = uriToFilePath ( 'file://project/main.ts' ) ;
39+ expect ( filePath ) . toBe ( '\\\\project\\main.ts' ) ;
40+ } ) ;
41+ }
42+
43+ if ( process . platform !== 'win32' ) {
44+ it ( 'should return valid fsPath for unix' , ( ) => {
45+ const filePath = uriToFilePath ( 'file:///project/main.ts' ) ;
46+ expect ( filePath ) . toBe ( '/project/main.ts' ) ;
47+ } ) ;
48+
49+ it ( 'should return valid fsPath for network file uri' , ( ) => {
50+ const filePath = uriToFilePath ( 'file://project/main.ts' ) ;
51+ expect ( filePath ) . toBe ( '//project/main.ts' ) ;
52+ } ) ;
53+ }
3354} ) ;
0 commit comments