forked from redhat-developer/yaml-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP Support schema associations in yaml files redhat-developer#204
Signed-off-by: Aurélien Pupier <[email protected]>
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { TextDocument } from 'vscode-languageserver'; | ||
import { getLanguageService } from '../src/languageservice/yamlLanguageService'; | ||
import { toFsPath, schemaRequestService, workspaceContext } from './utils/testHelper'; | ||
import assert = require('assert'); | ||
import path = require('path'); | ||
|
||
const languageService = getLanguageService(schemaRequestService, workspaceContext, [], null); | ||
|
||
const languageSettings = { | ||
schemas: [], | ||
completion: true | ||
}; | ||
|
||
const uri = toFsPath(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); | ||
languageService.configure(languageSettings); | ||
|
||
suite('Auto Completion Tests with schema defined in file', () => { | ||
|
||
describe('yamlCompletion with schema defined in file', function () { | ||
|
||
describe('doComplete', function () { | ||
|
||
function setup(content: string) { | ||
return TextDocument.create('file://~/Desktop/vscode-k8s/test.yaml', 'yaml', 0, content); | ||
} | ||
|
||
function parseSetup(content: string, position) { | ||
const testTextDocument = setup(content); | ||
return languageService.doComplete(testTextDocument, testTextDocument.positionAt(position), false); | ||
} | ||
|
||
it('Provide completion from schema decalred in file', done => { | ||
const content = `# yaml-language-server: $schema=${uri}\n- `; | ||
const completion = parseSetup(content, content.length); | ||
completion.then(function (result) { | ||
assert.equal(result.items.length, 3); | ||
}).then(done, done); | ||
}); | ||
|
||
it('Provide completion from schema declared in file overriding schemastore ', done => { | ||
|
||
}); | ||
|
||
it('Provide completion from schema declared in file overriding yaml.schemas ', done => { | ||
|
||
}); | ||
|
||
}); | ||
}); | ||
}); |