-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathfindDefintion.test.ts
More file actions
48 lines (43 loc) · 2.02 KB
/
findDefintion.test.ts
File metadata and controls
48 lines (43 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { getLanguageService } from '../src/languageservice/yamlLanguageService';
import { schemaRequestService, setupTextDocument, workspaceContext } from './utils/testHelper';
import assert = require('assert');
const languageService = getLanguageService(schemaRequestService, workspaceContext, [], null);
suite('FindDefintion Tests', () => {
describe('Jump to defintion', function () {
function findDefinitions(content: string, position: number) {
const testTextDocument = setupTextDocument(content);
return languageService.findDefinition(testTextDocument, testTextDocument.positionAt(position));
}
it('Find source defintion', done => {
const content = "definitions:\n link:\n type: string\ntype: object\nproperties:\n uri:\n $ref: '#/definitions/link'\n";
const definitions = findDefinitions(content, content.lastIndexOf('/li'));
definitions.then(function (results) {
assert.equal(results.length, 1);
assert.deepEqual(results[0].originSelectionRange, {
start: {
line: 6,
character: 10
},
end: {
line: 6,
character: 30
}
});
assert.deepEqual(results[0].targetRange, {
start: {
line: 2,
character: 4
},
end: {
line: 2,
character: 16
}
});
}).then(done, done);
});
});
});