@@ -4,11 +4,15 @@ import { createSpyConnection, createFakeEditor } from "../helpers.js"
4
4
import { Point , Range } from "atom"
5
5
import type { TextEditor } from "atom"
6
6
7
+ const setProcessPlatform = ( platform : any ) => {
8
+ Object . defineProperty ( process , "platform" , { value : platform } )
9
+ }
10
+
7
11
const callHierarchyItem : ls . CallHierarchyItem = {
8
12
name : "hello" ,
9
13
kind : 12 ,
10
14
detail : "" ,
11
- uri : "file:///C:/ path/to/file.ts" ,
15
+ uri : "file:///path/to/file.ts" ,
12
16
range : { start : { line : 0 , character : 0 } , end : { line : 1 , character : 1 } } ,
13
17
selectionRange : { start : { line : 0 , character : 24 } , end : { line : 0 , character : 29 } } ,
14
18
}
@@ -17,6 +21,14 @@ const callHierarchyItemWithTags: ls.CallHierarchyItem = {
17
21
kind : 12 ,
18
22
tags : [ 1 ] ,
19
23
detail : "" ,
24
+ uri : "file:///path/to/file.ts" ,
25
+ range : { start : { line : 0 , character : 0 } , end : { line : 1 , character : 1 } } ,
26
+ selectionRange : { start : { line : 0 , character : 24 } , end : { line : 0 , character : 29 } } ,
27
+ }
28
+ const callHierarchyItemInWin32 : ls . CallHierarchyItem = {
29
+ name : "hello" ,
30
+ kind : 12 ,
31
+ detail : "" ,
20
32
uri : "file:///C:/path/to/file.ts" ,
21
33
range : { start : { line : 0 , character : 0 } , end : { line : 1 , character : 1 } } ,
22
34
selectionRange : { start : { line : 0 , character : 24 } , end : { line : 0 , character : 29 } } ,
@@ -52,7 +64,7 @@ describe("OutlineViewAdapter", () => {
52
64
expect ( result . type ) . toEqual ( "incoming" )
53
65
expect ( result . data ) . toEqual ( [
54
66
{
55
- path : "C:\\path\\to\\file.ts" ,
67
+ path : jasmine . anything ( ) ,
56
68
name : "hello" ,
57
69
icon : "type-function" ,
58
70
tags : [ ] ,
@@ -71,7 +83,7 @@ describe("OutlineViewAdapter", () => {
71
83
expect ( result . type ) . toEqual ( "incoming" )
72
84
expect ( result . data ) . toEqual ( [
73
85
{
74
- path : "C:\\path\\to\\file.ts" ,
86
+ path : jasmine . anything ( ) ,
75
87
name : "hello" ,
76
88
icon : "type-function" ,
77
89
tags : [ "deprecated" ] ,
@@ -112,7 +124,7 @@ describe("OutlineViewAdapter", () => {
112
124
expect ( ( await result . itemAt ( 0 ) ) . type ) . toEqual ( "incoming" )
113
125
expect ( ( await result . itemAt ( 0 ) ) . data ) . toEqual ( [
114
126
{
115
- path : "C:\\path\\to\\file.ts" ,
127
+ path : jasmine . anything ( ) ,
116
128
name : "hello" ,
117
129
icon : "type-function" ,
118
130
tags : [ ] ,
@@ -125,7 +137,7 @@ describe("OutlineViewAdapter", () => {
125
137
expect ( ( await ( await result . itemAt ( 0 ) ) . itemAt ( 0 ) ) . type ) . toEqual ( "incoming" )
126
138
expect ( ( await ( await result . itemAt ( 0 ) ) . itemAt ( 0 ) ) . data ) . toEqual ( [
127
139
{
128
- path : "C:\\path\\to\\file.ts" ,
140
+ path : jasmine . anything ( ) ,
129
141
name : "hello" ,
130
142
icon : "type-function" ,
131
143
tags : [ ] ,
@@ -150,7 +162,7 @@ describe("OutlineViewAdapter", () => {
150
162
expect ( ( await result . itemAt ( 0 ) ) . type ) . toEqual ( "outgoing" )
151
163
expect ( ( await result . itemAt ( 0 ) ) . data ) . toEqual ( [
152
164
{
153
- path : "C:\\path\\to\\file.ts" ,
165
+ path : jasmine . anything ( ) ,
154
166
name : "hello" ,
155
167
icon : "type-function" ,
156
168
tags : [ ] ,
@@ -163,7 +175,7 @@ describe("OutlineViewAdapter", () => {
163
175
expect ( ( await ( await result . itemAt ( 0 ) ) . itemAt ( 0 ) ) . type ) . toEqual ( "outgoing" )
164
176
expect ( ( await ( await result . itemAt ( 0 ) ) . itemAt ( 0 ) ) . data ) . toEqual ( [
165
177
{
166
- path : "C:\\path\\to\\file.ts" ,
178
+ path : jasmine . anything ( ) ,
167
179
name : "hello" ,
168
180
icon : "type-function" ,
169
181
tags : [ ] ,
@@ -174,6 +186,22 @@ describe("OutlineViewAdapter", () => {
174
186
} ,
175
187
] )
176
188
} )
189
+ it ( "convert paths in darwin" , async ( ) => {
190
+ setProcessPlatform ( "darwin" )
191
+ spyOn ( connection , "prepareCallHierarchy" ) . and . resolveTo ( [ callHierarchyItem ] )
192
+ const result = < any > (
193
+ await new CallHierarchyAdapter ( ) . getCallHierarchy ( connection , fakeEditor , new Point ( 0 , 0 ) , "outgoing" )
194
+ )
195
+ expect ( result . data [ 0 ] . path ) . toEqual ( "/path/to/file.ts" )
196
+ } )
197
+ it ( "convert paths in win32" , async ( ) => {
198
+ setProcessPlatform ( "win32" )
199
+ spyOn ( connection , "prepareCallHierarchy" ) . and . resolveTo ( [ callHierarchyItemInWin32 ] )
200
+ const result = < any > (
201
+ await new CallHierarchyAdapter ( ) . getCallHierarchy ( connection , fakeEditor , new Point ( 0 , 0 ) , "outgoing" )
202
+ )
203
+ expect ( result . data [ 0 ] . path ) . toEqual ( "C:\\path\\to\\file.ts" )
204
+ } )
177
205
} )
178
206
179
207
describe ( "getIncoming" , ( ) => {
@@ -188,7 +216,7 @@ describe("OutlineViewAdapter", () => {
188
216
expect ( result . type ) . toEqual ( "incoming" )
189
217
expect ( result . data ) . toEqual ( [
190
218
{
191
- path : "C:\\path\\to\\file.ts" ,
219
+ path : jasmine . anything ( ) ,
192
220
name : "hello" ,
193
221
icon : "type-function" ,
194
222
tags : [ ] ,
@@ -211,6 +239,28 @@ describe("OutlineViewAdapter", () => {
211
239
expect ( result . type ) . toEqual ( "incoming" )
212
240
expect ( result . data ) . toEqual ( [ ] )
213
241
} )
242
+ it ( "convert paths in darwin" , async ( ) => {
243
+ setProcessPlatform ( "darwin" )
244
+ spyOn ( connection , "callHierarchyIncomingCalls" ) . and . resolveTo ( [
245
+ {
246
+ from : callHierarchyItem ,
247
+ fromRanges : [ ] ,
248
+ } ,
249
+ ] )
250
+ const result = < any > await new CallHierarchyAdapter ( ) . getIncoming ( connection , callHierarchyItem )
251
+ expect ( result . data [ 0 ] . path ) . toEqual ( "/path/to/file.ts" )
252
+ } )
253
+ it ( "convert paths in win32" , async ( ) => {
254
+ setProcessPlatform ( "win32" )
255
+ spyOn ( connection , "callHierarchyIncomingCalls" ) . and . resolveTo ( [
256
+ {
257
+ from : callHierarchyItemInWin32 ,
258
+ fromRanges : [ ] ,
259
+ } ,
260
+ ] )
261
+ const result = < any > await new CallHierarchyAdapter ( ) . getIncoming ( connection , callHierarchyItem )
262
+ expect ( result . data [ 0 ] . path ) . toEqual ( "C:\\path\\to\\file.ts" )
263
+ } )
214
264
} )
215
265
216
266
describe ( "getOutgoing" , ( ) => {
@@ -225,7 +275,7 @@ describe("OutlineViewAdapter", () => {
225
275
expect ( result . type ) . toEqual ( "outgoing" )
226
276
expect ( result . data ) . toEqual ( [
227
277
{
228
- path : "C:\\path\\to\\file.ts" ,
278
+ path : jasmine . anything ( ) ,
229
279
name : "hello" ,
230
280
icon : "type-function" ,
231
281
tags : [ ] ,
@@ -248,5 +298,27 @@ describe("OutlineViewAdapter", () => {
248
298
expect ( result . type ) . toEqual ( "outgoing" )
249
299
expect ( result . data ) . toEqual ( [ ] )
250
300
} )
301
+ it ( "convert paths in darwin" , async ( ) => {
302
+ setProcessPlatform ( "darwin" )
303
+ spyOn ( connection , "callHierarchyOutgoingCalls" ) . and . resolveTo ( [
304
+ {
305
+ to : callHierarchyItem ,
306
+ fromRanges : [ ] ,
307
+ } ,
308
+ ] )
309
+ const result = < any > await new CallHierarchyAdapter ( ) . getOutgoing ( connection , callHierarchyItem )
310
+ expect ( result . data [ 0 ] . path ) . toEqual ( "/path/to/file.ts" )
311
+ } )
312
+ it ( "convert paths in win32" , async ( ) => {
313
+ setProcessPlatform ( "win32" )
314
+ spyOn ( connection , "callHierarchyOutgoingCalls" ) . and . resolveTo ( [
315
+ {
316
+ to : callHierarchyItemInWin32 ,
317
+ fromRanges : [ ] ,
318
+ } ,
319
+ ] )
320
+ const result = < any > await new CallHierarchyAdapter ( ) . getOutgoing ( connection , callHierarchyItem )
321
+ expect ( result . data [ 0 ] . path ) . toEqual ( "C:\\path\\to\\file.ts" )
322
+ } )
251
323
} )
252
324
} )
0 commit comments