| 1 | import { PYTHON_TEST_CASES, TYPESCRIPT_TEST_CASES } from "./testCases"; |
| 2 | import { testRootPathContext } from "./testUtils"; |
| 3 | |
| 4 | const TEST_CASES = [ |
| 5 | ...PYTHON_TEST_CASES, |
| 6 | ...TYPESCRIPT_TEST_CASES, |
| 7 | { |
| 8 | nodeType: "function_definition", |
| 9 | fileName: "file1.php", |
| 10 | language: "PHP", |
| 11 | cursorPosition: { line: 12, character: 32 }, |
| 12 | definitionPositions: [ |
| 13 | { row: 10, column: 26 }, // Person |
| 14 | { row: 10, column: 44 }, // Address |
| 15 | ], |
| 16 | }, |
| 17 | { |
| 18 | nodeType: "method_declaration", |
| 19 | fileName: "file1.php", |
| 20 | language: "PHP", |
| 21 | cursorPosition: { line: 26, character: 35 }, |
| 22 | definitionPositions: [ |
| 23 | { row: 15, column: 29 }, // BaseClass |
| 24 | { row: 15, column: 55 }, // FirstInterface |
| 25 | { row: 15, column: 72 }, // SecondInterface |
| 26 | { row: 25, column: 43 }, // Person |
| 27 | { row: 25, column: 61 }, // Address |
| 28 | ], |
| 29 | }, |
| 30 | { |
| 31 | nodeType: "function_declaration", |
| 32 | fileName: "file1.go", |
| 33 | language: "Go", |
| 34 | cursorPosition: { line: 7, character: 21 }, |
| 35 | definitionPositions: [ |
| 36 | { row: 6, column: 33 }, // models.User |
| 37 | { row: 6, column: 50 }, // models.Address |
| 38 | ], |
| 39 | }, |
| 40 | ]; |
| 41 | |
| 42 | describe("RootPathContextService", () => { |
| 43 | describe("should look for correct type definitions", () => { |
| 44 | test.each(TEST_CASES)( |
| 45 | "$language: $nodeType", |
| 46 | async ({ fileName, cursorPosition, definitionPositions }) => { |
| 47 | await testRootPathContext( |
| 48 | "files", |
| 49 | fileName, |
| 50 | cursorPosition, |
| 51 | definitionPositions, |
| 52 | ); |
| 53 | }, |
| 54 | ); |
| 55 | }); |
| 56 | }); |