[json] better support for null, and array of types

This commit is contained in:
Martin Aeschlimann
2016-02-10 12:09:34 +01:00
parent 0f6a10b4b0
commit b7e6e6fae7
3 changed files with 55 additions and 10 deletions

View File

@@ -29,7 +29,7 @@ suite('JSON Completion', () => {
assert.equal(applyEdits(document, [ matches[0].textEdit ]), resultText);
}
};
var testSuggestionsFor = function(value: string, stringAfter: string, schema: JsonSchema.IJSONSchema, test: (items: CompletionItem[], document: ITextDocument) => void) : Thenable<void> {
var uri = 'test://test.json';
@@ -191,6 +191,34 @@ suite('JSON Completion', () => {
]).then(() => testDone(), (error) => testDone(error));
});
test('Complete value with schema: booleans, null', function(testDone) {
var schema: JsonSchema.IJSONSchema = {
type: 'object',
properties: {
'a': {
type: 'boolean'
},
'b': {
type: ['boolean', 'null']
},
}
};
Promise.all([
testSuggestionsFor('{ "a": /**/ }', '/**/', schema, result => {
assert.strictEqual(result.length, 2);
assertSuggestion(result, 'true');
assertSuggestion(result, 'false');
}),
testSuggestionsFor('{ "b": "/**/ }', '/**/', schema, result => {
assert.strictEqual(result.length, 3);
assertSuggestion(result, 'true');
assertSuggestion(result, 'false');
assertSuggestion(result, 'null');
})
]).then(() => testDone(), (error) => testDone(error));
});
test('Complete with nested schema', function(testDone) {
var content = '{/**/}';