@@ -2,41 +2,62 @@ import { testRootPathContext } from "./testUtils";
2
2
3
3
const TEST_CASES = [
4
4
{
5
- description : "function " ,
5
+ nodeType : "function_declaration " ,
6
6
fileName : "file1.ts" ,
7
- range : {
8
- start : { line : 10 , character : 2 } ,
9
- end : { line : 10 , character : 24 } ,
10
- } ,
11
- positions : [
7
+ language : "TypeScript" ,
8
+ cursorPosition : { line : 10 , character : 24 } ,
9
+ definitionPositions : [
12
10
{ row : 9 , column : 34 } , // Person
13
11
{ row : 9 , column : 44 } , // Address
14
12
] ,
15
13
} ,
16
14
{
17
- description : "class method " ,
15
+ nodeType : "method_declaration " ,
18
16
fileName : "file1.ts" ,
19
- range : {
20
- start : { line : 22 , character : 4 } ,
21
- end : { line : 22 , character : 30 } ,
22
- } ,
23
- positions : [
17
+ language : "TypeScript" ,
18
+ cursorPosition : { line : 22 , character : 30 } ,
19
+ definitionPositions : [
24
20
{ row : 13 , column : 29 } , // BaseClass
25
21
{ row : 13 , column : 55 } , // FirstInterface
26
22
{ row : 13 , column : 72 } , // SecondInterface
27
23
{ row : 21 , column : 33 } , // Person
28
24
{ row : 21 , column : 43 } , // Address
29
25
] ,
30
26
} ,
27
+ {
28
+ nodeType : "function_definition" ,
29
+ fileName : "file1.py" ,
30
+ language : "Python" ,
31
+ cursorPosition : { line : 4 , character : 25 } ,
32
+ definitionPositions : [
33
+ { row : 3 , column : 30 } , // Person
34
+ { row : 3 , column : 42 } , // Address
35
+ ] ,
36
+ } ,
37
+ {
38
+ nodeType : "function_definition (inside a class)" ,
39
+ fileName : "file1.py" ,
40
+ language : "Python" ,
41
+ cursorPosition : { line : 12 , character : 33 } ,
42
+ definitionPositions : [
43
+ { row : 6 , column : 21 } , // BaseClass
44
+ { row : 6 , column : 33 } , // Collection
45
+ { row : 11 , column : 47 } , // Person
46
+ { row : 11 , column : 59 } , // Address
47
+ ] ,
48
+ } ,
31
49
] ;
32
50
33
51
describe ( "RootPathContextService" , ( ) => {
34
- describe ( "TypeScript should return expected snippets when editing inside a:" , ( ) => {
35
- test . each ( TEST_CASES ) (
36
- "should look for correct type definitions when editing inside a $description" ,
37
- async ( { fileName, range, positions } ) => {
38
- await testRootPathContext ( "typescript" , fileName , range , positions ) ;
39
- } ,
40
- ) ;
41
- } ) ;
52
+ test . each ( TEST_CASES ) (
53
+ "Should look for correct type definitions when editing inside a $nodeType in $language" ,
54
+ async ( { fileName, cursorPosition, definitionPositions } ) => {
55
+ await testRootPathContext (
56
+ "files" ,
57
+ fileName ,
58
+ cursorPosition ,
59
+ definitionPositions ,
60
+ ) ;
61
+ } ,
62
+ ) ;
42
63
} ) ;
0 commit comments