mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-18 05:51:07 +00:00
style: lint files
This commit is contained in:
parent
1e0e5ebb54
commit
84e82b52f7
22 changed files with 338 additions and 317 deletions
|
|
@ -213,7 +213,7 @@ export interface ISchemaCollector {
|
|||
|
||||
class SchemaCollector implements ISchemaCollector {
|
||||
public schemas: IApplicableSchema[] = [];
|
||||
constructor(private focusOffset = -1, private exclude: ASTNode = null) { }
|
||||
constructor(private focusOffset = -1, private exclude: ASTNode = null) {}
|
||||
public add(schema: IApplicableSchema) {
|
||||
this.schemas.push(schema);
|
||||
}
|
||||
|
|
@ -237,9 +237,9 @@ class NoOpSchemaCollector implements ISchemaCollector {
|
|||
}
|
||||
|
||||
public static instance = new NoOpSchemaCollector();
|
||||
private constructor() { }
|
||||
public add(schema: IApplicableSchema) { }
|
||||
public merge(other: ISchemaCollector) { }
|
||||
private constructor() {}
|
||||
public add(schema: IApplicableSchema) {}
|
||||
public merge(other: ISchemaCollector) {}
|
||||
public include(node: ASTNode) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ export class JSONDocument {
|
|||
public root: ASTNode,
|
||||
public readonly syntaxErrors: Diagnostic[] = [],
|
||||
public readonly comments: Range[] = []
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public getNodeFromOffset(
|
||||
offset: number,
|
||||
|
|
@ -1110,13 +1110,15 @@ function validate(
|
|||
break;
|
||||
}
|
||||
case 'array': {
|
||||
propertyNode.valueNode.items.forEach((sequenceNode: ObjectASTNode) => {
|
||||
sequenceNode.properties.forEach(propASTNode => {
|
||||
const seqKey = propASTNode.keyNode.value;
|
||||
seenKeys[seqKey] = propASTNode.valueNode;
|
||||
unprocessedProperties.push(seqKey);
|
||||
});
|
||||
});
|
||||
propertyNode.valueNode.items.forEach(
|
||||
(sequenceNode: ObjectASTNode) => {
|
||||
sequenceNode.properties.forEach(propASTNode => {
|
||||
const seqKey = propASTNode.keyNode.value;
|
||||
seenKeys[seqKey] = propASTNode.valueNode;
|
||||
unprocessedProperties.push(seqKey);
|
||||
});
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
|||
|
|
@ -226,11 +226,10 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
|||
function convertError(e: Yaml.Error) {
|
||||
return {
|
||||
message: `${e.reason}`,
|
||||
// TODO: YAML ast parser does not give a length for validation error,
|
||||
// TODO: thus we treat the range from line start to the target position.
|
||||
// TODO: YAML ast parser does not give a length for validation error.
|
||||
location: {
|
||||
offset: e.mark.position - e.mark.column,
|
||||
length: e.mark.column,
|
||||
offset: e.mark.position,
|
||||
length: 0,
|
||||
},
|
||||
code: ErrorCode.Undefined,
|
||||
severity: e.isWarning
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ export class JSONSchemaService implements IJSONSchemaService {
|
|||
next.allOf,
|
||||
next.oneOf,
|
||||
next.items as JSONSchema[],
|
||||
next.schemaSequence,
|
||||
next.schemaSequence
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ export class YamlFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
doFormat(
|
||||
document: TextDocument,
|
||||
options: FormattingOptions,
|
||||
): TextEdit[] {
|
||||
doFormat(document: TextDocument, options: FormattingOptions): TextEdit[] {
|
||||
const text = document.getText();
|
||||
const customTags = this.customTags || [];
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ export class YAMLHover {
|
|||
private contributions: JSONWorkerContribution[] = []
|
||||
) {}
|
||||
|
||||
public configure(languageSettings: LanguageSettings){
|
||||
if(languageSettings){
|
||||
this.shouldHover = !!languageSettings.hover;
|
||||
}
|
||||
}
|
||||
public configure(languageSettings: LanguageSettings) {
|
||||
if (languageSettings) {
|
||||
this.shouldHover = !!languageSettings.hover;
|
||||
}
|
||||
}
|
||||
|
||||
public doHover(
|
||||
document: TextDocument,
|
||||
|
|
@ -95,8 +95,14 @@ export class YAMLHover {
|
|||
.then(schema => {
|
||||
if (schema) {
|
||||
let newSchema = schema;
|
||||
if (schema.schema && schema.schema.schemaSequence && schema.schema.schemaSequence[currentDocIndex]) {
|
||||
newSchema = new SchemaService.ResolvedSchema(schema.schema.schemaSequence[currentDocIndex]);
|
||||
if (
|
||||
schema.schema &&
|
||||
schema.schema.schemaSequence &&
|
||||
schema.schema.schemaSequence[currentDocIndex]
|
||||
) {
|
||||
newSchema = new SchemaService.ResolvedSchema(
|
||||
schema.schema.schemaSequence[currentDocIndex]
|
||||
);
|
||||
}
|
||||
|
||||
const matchingSchemas = currentDoc.getMatchingSchemas(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { DiagnosticSeverity, TextDocument, Diagnostic } from 'vscode-languageserver-types';
|
||||
import {
|
||||
DiagnosticSeverity,
|
||||
TextDocument,
|
||||
Diagnostic,
|
||||
} from 'vscode-languageserver-types';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
import { YAMLDocument } from '../yamlLanguageTypes';
|
||||
import { JSONSchemaService, ResolvedSchema } from './jsonSchemaService';
|
||||
|
|
@ -23,13 +27,16 @@ export class YAMLValidation {
|
|||
}
|
||||
}
|
||||
|
||||
public doValidation(textDocument: TextDocument, yamlDocument: YAMLDocument): Thenable<Diagnostic[]> {
|
||||
public doValidation(
|
||||
textDocument: TextDocument,
|
||||
yamlDocument: YAMLDocument
|
||||
): Thenable<Diagnostic[]> {
|
||||
if (!this.validationEnabled) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return this.jsonSchemaService
|
||||
.getSchemaForResource(textDocument.uri)
|
||||
.then(function (schema) {
|
||||
.then(function(schema) {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
const added = {};
|
||||
let newSchema = schema;
|
||||
|
|
@ -55,7 +62,9 @@ export class YAMLValidation {
|
|||
currentDoc.errors.push({
|
||||
location: {
|
||||
offset: textDocument.offsetAt(curDiagnostic.range.start),
|
||||
length: textDocument.offsetAt(curDiagnostic.range.end) - textDocument.offsetAt(curDiagnostic.range.start),
|
||||
length:
|
||||
textDocument.offsetAt(curDiagnostic.range.end) -
|
||||
textDocument.offsetAt(curDiagnostic.range.start),
|
||||
},
|
||||
message: curDiagnostic.message,
|
||||
severity: curDiagnostic.severity,
|
||||
|
|
@ -86,7 +95,7 @@ export class YAMLValidation {
|
|||
const currentDoc = yamlDocument.documents[currentYAMLDoc];
|
||||
currentDoc.errors
|
||||
.concat(currentDoc.warnings)
|
||||
.forEach(function (error, idx) {
|
||||
.forEach(function(error, idx) {
|
||||
// remove duplicated messages
|
||||
const signature =
|
||||
error.location.offset +
|
||||
|
|
@ -103,7 +112,9 @@ export class YAMLValidation {
|
|||
: DiagnosticSeverity.Error,
|
||||
range: {
|
||||
start: textDocument.positionAt(error.location.offset),
|
||||
end: textDocument.positionAt(error.location.offset + error.location.length),
|
||||
end: textDocument.positionAt(
|
||||
error.location.offset + error.location.length
|
||||
),
|
||||
},
|
||||
message: error.message,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import {
|
|||
const assert = require('assert');
|
||||
|
||||
describe('Array Utils Tests', () => {
|
||||
describe('Server - Array Utils', function () {
|
||||
describe('removeDuplicates', function () {
|
||||
describe('Server - Array Utils', function() {
|
||||
describe('removeDuplicates', function() {
|
||||
it('Remove one duplicate with property', () => {
|
||||
const obj1 = {
|
||||
test_key: 'test_value',
|
||||
|
|
@ -69,7 +69,7 @@ describe('Array Utils Tests', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('getLineOffsets', function () {
|
||||
describe('getLineOffsets', function() {
|
||||
it('No offset', () => {
|
||||
const offsets = getLineOffsets('');
|
||||
assert.equal(offsets.length, 0);
|
||||
|
|
@ -89,7 +89,7 @@ describe('Array Utils Tests', () => {
|
|||
|
||||
it('Multiple offsets', () => {
|
||||
const offsets = getLineOffsets(
|
||||
'first_offset\n second_offset\n third_offset',
|
||||
'first_offset\n second_offset\n third_offset'
|
||||
);
|
||||
assert.equal(offsets.length, 3);
|
||||
assert.equal(offsets[0], 0);
|
||||
|
|
@ -98,7 +98,7 @@ describe('Array Utils Tests', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('removeDuplicatesObj', function () {
|
||||
describe('removeDuplicatesObj', function() {
|
||||
it('Remove one duplicate with property', () => {
|
||||
const obj1 = {
|
||||
test_key: 'test_value',
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/bowerrc';
|
||||
|
|
@ -25,14 +25,14 @@ languageSettings.schemas.push({ uri, fileMatch });
|
|||
languageService.configure(languageSettings);
|
||||
|
||||
describe('Auto Completion Tests', () => {
|
||||
describe('yamlCompletion with bowerrc', function () {
|
||||
describe('doComplete', function () {
|
||||
describe('yamlCompletion with bowerrc', function() {
|
||||
describe('doComplete', function() {
|
||||
function setup(content: string) {
|
||||
return TextDocument.create(
|
||||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -40,145 +40,145 @@ describe('Auto Completion Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
return completionHelper(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
testTextDocument.positionAt(position)
|
||||
);
|
||||
}
|
||||
|
||||
it('Autocomplete on root node without word', (done) => {
|
||||
it('Autocomplete on root node without word', done => {
|
||||
const content = '';
|
||||
const completion = parseSetup(content, 0);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on root node with word', (done) => {
|
||||
it('Autocomplete on root node with word', done => {
|
||||
const content = 'analyt';
|
||||
const completion = parseSetup(content, 6);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on default value (without value content)', (done) => {
|
||||
it('Autocomplete on default value (without value content)', done => {
|
||||
const content = 'directory: ';
|
||||
const completion = parseSetup(content, 12);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.items.length).toEqual(1);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on default value (with value content)', (done) => {
|
||||
it('Autocomplete on default value (with value content)', done => {
|
||||
const content = 'directory: bow';
|
||||
const completion = parseSetup(content, 15);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on boolean value (without value content)', (done) => {
|
||||
it('Autocomplete on boolean value (without value content)', done => {
|
||||
const content = 'analytics: ';
|
||||
const completion = parseSetup(content, 11);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.items.length).toEqual(2);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on boolean value (with value content)', (done) => {
|
||||
it('Autocomplete on boolean value (with value content)', done => {
|
||||
const content = 'analytics: fal';
|
||||
const completion = parseSetup(content, 11);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.equal(result.items.length, 2);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on number value (without value content)', (done) => {
|
||||
it('Autocomplete on number value (without value content)', done => {
|
||||
const content = 'timeout: ';
|
||||
const completion = parseSetup(content, 9);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.items.length).toEqual(1);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on number value (with value content)', (done) => {
|
||||
it('Autocomplete on number value (with value content)', done => {
|
||||
const content = 'timeout: 6';
|
||||
const completion = parseSetup(content, 10);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.equal(result.items.length, 1);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete key in middle of file', (done) => {
|
||||
it('Autocomplete key in middle of file', done => {
|
||||
const content = 'scripts:\n post';
|
||||
const completion = parseSetup(content, 11);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete key in middle of file 2', (done) => {
|
||||
it('Autocomplete key in middle of file 2', done => {
|
||||
const content = 'scripts:\n postinstall: /test\n preinsta';
|
||||
const completion = parseSetup(content, 31);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete does not happen right after :', (done) => {
|
||||
it('Autocomplete does not happen right after :', done => {
|
||||
const content = 'analytics:';
|
||||
const completion = parseSetup(content, 9);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete does not happen right after : under an object', (done) => {
|
||||
it('Autocomplete does not happen right after : under an object', done => {
|
||||
const content = 'scripts:\n postinstall:';
|
||||
const completion = parseSetup(content, 21);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on multi yaml documents in a single file on root', (done) => {
|
||||
it('Autocomplete on multi yaml documents in a single file on root', done => {
|
||||
const content = `---\nanalytics: true\n...\n---\n...`;
|
||||
const completion = parseSetup(content, 28);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on multi yaml documents in a single file on scalar', (done) => {
|
||||
it('Autocomplete on multi yaml documents in a single file on scalar', done => {
|
||||
const content = `---\nanalytics: true\n...\n---\njson: \n...`;
|
||||
const completion = parseSetup(content, 34);
|
||||
completion
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.items.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/composer';
|
||||
|
|
@ -30,7 +30,7 @@ describe('Auto Completion Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -38,13 +38,13 @@ describe('Auto Completion Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
return completionHelper(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
testTextDocument.positionAt(position)
|
||||
);
|
||||
}
|
||||
|
||||
describe('yamlCompletion with composer', function() {
|
||||
describe('doComplete', function() {
|
||||
it('Array autocomplete without word', (done) => {
|
||||
it('Array autocomplete without word', done => {
|
||||
const content = 'authors:\n - ';
|
||||
const completion = parseSetup(content, 14);
|
||||
completion
|
||||
|
|
@ -54,7 +54,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array autocomplete without word on array symbol', (done) => {
|
||||
it('Array autocomplete without word on array symbol', done => {
|
||||
const content = 'authors:\n -';
|
||||
const completion = parseSetup(content, 13);
|
||||
completion
|
||||
|
|
@ -64,7 +64,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array autocomplete without word on space before array symbol', (done) => {
|
||||
it('Array autocomplete without word on space before array symbol', done => {
|
||||
const content = 'authors:\n - name: test\n ';
|
||||
const completion = parseSetup(content, 24);
|
||||
completion
|
||||
|
|
@ -74,7 +74,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array autocomplete with letter', (done) => {
|
||||
it('Array autocomplete with letter', done => {
|
||||
const content = 'authors:\n - n';
|
||||
const completion = parseSetup(content, 14);
|
||||
completion
|
||||
|
|
@ -84,7 +84,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array autocomplete without word (second item)', (done) => {
|
||||
it('Array autocomplete without word (second item)', done => {
|
||||
const content = 'authors:\n - name: test\n ';
|
||||
const completion = parseSetup(content, 32);
|
||||
completion
|
||||
|
|
@ -94,7 +94,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array autocomplete with letter (second item)', (done) => {
|
||||
it('Array autocomplete with letter (second item)', done => {
|
||||
const content = 'authors:\n - name: test\n e';
|
||||
const completion = parseSetup(content, 27);
|
||||
completion
|
||||
|
|
@ -104,7 +104,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocompletion after array', (done) => {
|
||||
it('Autocompletion after array', done => {
|
||||
const content = 'authors:\n - name: test\n';
|
||||
const completion = parseSetup(content, 24);
|
||||
completion
|
||||
|
|
@ -114,7 +114,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocompletion after array with depth', (done) => {
|
||||
it('Autocompletion after array with depth', done => {
|
||||
const content = 'archive:\n exclude:\n - test\n';
|
||||
const completion = parseSetup(content, 29);
|
||||
completion
|
||||
|
|
@ -124,7 +124,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocompletion after array with depth', (done) => {
|
||||
it('Autocompletion after array with depth', done => {
|
||||
const content =
|
||||
'autoload:\n classmap:\n - test\n exclude-from-classmap:\n - test\n ';
|
||||
const completion = parseSetup(content, 70);
|
||||
|
|
@ -137,7 +137,7 @@ describe('Auto Completion Tests', () => {
|
|||
});
|
||||
|
||||
describe('Failure tests', function() {
|
||||
it('Autocompletion has no results on value when they are not available', (done) => {
|
||||
it('Autocompletion has no results on value when they are not available', done => {
|
||||
const content = 'time: ';
|
||||
const completion = parseSetup(content, 6);
|
||||
completion
|
||||
|
|
@ -147,7 +147,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocompletion has no results on value when they are not available (with depth)', (done) => {
|
||||
it('Autocompletion has no results on value when they are not available (with depth)', done => {
|
||||
const content = 'archive:\n exclude:\n - test\n ';
|
||||
const completion = parseSetup(content, 33);
|
||||
completion
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/asmdef';
|
||||
|
|
@ -32,7 +32,7 @@ describe('Auto Completion Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -40,11 +40,11 @@ describe('Auto Completion Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
return completionHelper(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
testTextDocument.positionAt(position)
|
||||
);
|
||||
}
|
||||
|
||||
it('Array of enum autocomplete without word on array symbol', (done) => {
|
||||
it('Array of enum autocomplete without word on array symbol', done => {
|
||||
const content = 'optionalUnityReferences:\n -';
|
||||
const completion = parseSetup(content, 29);
|
||||
completion
|
||||
|
|
@ -54,7 +54,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array of enum autocomplete without word', (done) => {
|
||||
it('Array of enum autocomplete without word', done => {
|
||||
const content = 'optionalUnityReferences:\n - ';
|
||||
const completion = parseSetup(content, 30);
|
||||
completion
|
||||
|
|
@ -64,7 +64,7 @@ describe('Auto Completion Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Array of enum autocomplete with letter', (done) => {
|
||||
it('Array of enum autocomplete with letter', done => {
|
||||
const content = 'optionalUnityReferences:\n - T';
|
||||
const completion = parseSetup(content, 31);
|
||||
completion
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
// TODO: this suite is outdated and should be updated.
|
||||
|
|
@ -24,7 +24,7 @@ xdescribe('Document Symbols Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -33,67 +33,67 @@ xdescribe('Document Symbols Tests', () => {
|
|||
const jsonDocument = parseYAML(testTextDocument.getText());
|
||||
return languageService.findDocumentSymbols(
|
||||
testTextDocument,
|
||||
jsonDocument,
|
||||
jsonDocument
|
||||
);
|
||||
}
|
||||
|
||||
it('Document is empty', (done) => {
|
||||
it('Document is empty', done => {
|
||||
const content = '';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols, null);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Simple document symbols', (done) => {
|
||||
it('Simple document symbols', done => {
|
||||
const content = 'cwd: test';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with number', (done) => {
|
||||
it('Document Symbols with number', done => {
|
||||
const content = 'node1: 10000';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with boolean', (done) => {
|
||||
it('Document Symbols with boolean', done => {
|
||||
const content = 'node1: False';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with object', (done) => {
|
||||
it('Document Symbols with object', done => {
|
||||
const content = 'scripts:\n node1: test\n node2: test';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 3);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with null', (done) => {
|
||||
it('Document Symbols with null', done => {
|
||||
const content = 'apiVersion: null';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with array of strings', (done) => {
|
||||
it('Document Symbols with array of strings', done => {
|
||||
const content = 'items:\n - test\n - test';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with array', (done) => {
|
||||
it('Document Symbols with array', done => {
|
||||
const content = 'authors:\n - name: Josh\n - email: jp';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 3);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with object and array', (done) => {
|
||||
it('Document Symbols with object and array', done => {
|
||||
const content =
|
||||
'scripts:\n node1: test\n node2: test\nauthors:\n - name: Josh\n - email: jp';
|
||||
const symbols = parseSetup(content);
|
||||
|
|
@ -101,7 +101,7 @@ xdescribe('Document Symbols Tests', () => {
|
|||
done();
|
||||
});
|
||||
|
||||
it('Document Symbols with multi documents', (done) => {
|
||||
it('Document Symbols with multi documents', done => {
|
||||
const content = '---\nanalytics: true\n...\n---\njson: test\n...';
|
||||
const symbols = parseSetup(content);
|
||||
assert.equal(symbols.length, 2);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/bowerrc';
|
||||
|
|
@ -32,7 +32,7 @@ describe('Formatter Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ describe('Formatter Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
const edits = languageService.doFormat(
|
||||
testTextDocument,
|
||||
{} as FormattingOptions,
|
||||
{} as FormattingOptions
|
||||
);
|
||||
assert.notEqual(edits.length, 0);
|
||||
assert.equal(edits[0].newText, 'cwd: test\n');
|
||||
|
|
@ -53,7 +53,7 @@ describe('Formatter Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
const edits = languageService.doFormat(
|
||||
testTextDocument,
|
||||
{} as FormattingOptions,
|
||||
{} as FormattingOptions
|
||||
);
|
||||
assert.notEqual(edits.length, 0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'vscode-languageserver';
|
||||
import { parse as parseYAML } from '../src/languageservice/parser/yamlParser';
|
||||
import { getLanguageService, LanguageSettings } from '../src/languageservice/yamlLanguageService';
|
||||
import {
|
||||
getLanguageService,
|
||||
LanguageSettings,
|
||||
} from '../src/languageservice/yamlLanguageService';
|
||||
import { schemaRequestService, workspaceContext } from './testHelper';
|
||||
const assert = require('assert');
|
||||
|
||||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/bowerrc';
|
||||
|
|
@ -24,14 +27,14 @@ languageSettings.schemas.push({ uri, fileMatch });
|
|||
languageService.configure(languageSettings);
|
||||
|
||||
describe('Hover Tests', () => {
|
||||
describe('Yaml Hover with bowerrc', function () {
|
||||
describe('doComplete', function () {
|
||||
describe('Yaml Hover with bowerrc', function() {
|
||||
describe('doComplete', function() {
|
||||
function setup(content: string) {
|
||||
return TextDocument.create(
|
||||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -41,81 +44,81 @@ describe('Hover Tests', () => {
|
|||
return languageService.doHover(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
jsonDocument,
|
||||
jsonDocument
|
||||
);
|
||||
}
|
||||
|
||||
it('Hover on key on root', (done) => {
|
||||
it('Hover on key on root', done => {
|
||||
const content = 'cwd: test';
|
||||
const hover = parseSetup(content, 1);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover on value on root', (done) => {
|
||||
it('Hover on value on root', done => {
|
||||
const content = 'cwd: test';
|
||||
const hover = parseSetup(content, 6);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover on key with depth', (done) => {
|
||||
it('Hover on key with depth', done => {
|
||||
const content = 'scripts:\n postinstall: test';
|
||||
const hover = parseSetup(content, 15);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover on value with depth', (done) => {
|
||||
it('Hover on value with depth', done => {
|
||||
const content = 'scripts:\n postinstall: test';
|
||||
const hover = parseSetup(content, 26);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover works on both root node and child nodes works', (done) => {
|
||||
it('Hover works on both root node and child nodes works', done => {
|
||||
const content = 'scripts:\n postinstall: test';
|
||||
|
||||
const firstHover = parseSetup(content, 3);
|
||||
firstHover.then(function (result) {
|
||||
firstHover.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
});
|
||||
|
||||
const secondHover = parseSetup(content, 15);
|
||||
secondHover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover does not show results when there isnt description field', (done) => {
|
||||
it('Hover does not show results when there isnt description field', done => {
|
||||
const content = 'analytics: true';
|
||||
const hover = parseSetup(content, 3);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover on multi document', (done) => {
|
||||
it('Hover on multi document', done => {
|
||||
const content = '---\nanalytics: true\n...\n---\njson: test\n...';
|
||||
const hover = parseSetup(content, 30);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/composer';
|
||||
|
|
@ -34,7 +34,7 @@ describe('Hover Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -44,11 +44,11 @@ describe('Hover Tests', () => {
|
|||
return languageService.doHover(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
jsonDocument,
|
||||
jsonDocument
|
||||
);
|
||||
}
|
||||
|
||||
it('Hover works on array nodes', (done) => {
|
||||
it('Hover works on array nodes', done => {
|
||||
const content = 'authors:\n - name: Josh';
|
||||
const hover = parseSetup(content, 14);
|
||||
hover
|
||||
|
|
@ -58,7 +58,7 @@ describe('Hover Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Hover works on array nodes 2', (done) => {
|
||||
it('Hover works on array nodes 2', done => {
|
||||
const content = 'authors:\n - name: Josh\n - email: jp';
|
||||
const hover = parseSetup(content, 28);
|
||||
hover
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TextDocument } from 'vscode-languageserver';
|
||||
import { parse as parseYAML } from '../src/languageservice/parser/yamlParser';
|
||||
import { getLanguageService, LanguageSettings } from '../src/languageservice/yamlLanguageService';
|
||||
import {
|
||||
getLanguageService,
|
||||
LanguageSettings,
|
||||
} from '../src/languageservice/yamlLanguageService';
|
||||
import { schemaRequestService, workspaceContext } from './testHelper';
|
||||
const assert = require('assert');
|
||||
|
||||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/bowerrc';
|
||||
|
|
@ -24,14 +27,14 @@ languageSettings.schemas.push({ uri, fileMatch });
|
|||
languageService.configure(languageSettings);
|
||||
|
||||
describe('Hover Setting Tests', () => {
|
||||
describe('Yaml Hover with bowerrc', function () {
|
||||
describe('doComplete', function () {
|
||||
describe('Yaml Hover with bowerrc', function() {
|
||||
describe('doComplete', function() {
|
||||
function setup(content: string) {
|
||||
return TextDocument.create(
|
||||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -41,15 +44,15 @@ describe('Hover Setting Tests', () => {
|
|||
return languageService.doHover(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
jsonDocument,
|
||||
jsonDocument
|
||||
);
|
||||
}
|
||||
|
||||
it('Hover should not return anything', (done) => {
|
||||
it('Hover should not return anything', done => {
|
||||
const content = 'cwd: test';
|
||||
const hover = parseSetup(content, 1);
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.equal(result, undefined);
|
||||
})
|
||||
.then(done, done);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri =
|
||||
|
|
@ -34,7 +34,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
|
||||
// Validating basic nodes
|
||||
describe('Test that validation does not throw errors', function() {
|
||||
it('Basic test', (done) => {
|
||||
it('Basic test', done => {
|
||||
const content = `apiVersion: v1`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -56,7 +56,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Basic test on nodes with children', (done) => {
|
||||
it('Basic test on nodes with children', done => {
|
||||
const content = `metadata:\n name: hello`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -66,7 +66,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Advanced test on nodes with children', (done) => {
|
||||
it('Advanced test on nodes with children', done => {
|
||||
const content = `apiVersion: v1\nmetadata:\n name: test1`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -76,7 +76,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type string validates under children', (done) => {
|
||||
it('Type string validates under children', done => {
|
||||
const content = `apiVersion: v1\nkind: Pod\nmetadata:\n resourceVersion: test`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -87,7 +87,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
});
|
||||
|
||||
describe('Type tests', function() {
|
||||
it('Type String does not error on valid node', (done) => {
|
||||
it('Type String does not error on valid node', done => {
|
||||
const content = `apiVersion: v1`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -97,7 +97,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Boolean does not error on valid node', (done) => {
|
||||
it('Type Boolean does not error on valid node', done => {
|
||||
const content = `readOnlyRootFilesystem: false`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -107,7 +107,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Number does not error on valid node', (done) => {
|
||||
it('Type Number does not error on valid node', done => {
|
||||
const content = `generation: 5`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -117,7 +117,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Object does not error on valid node', (done) => {
|
||||
it('Type Object does not error on valid node', done => {
|
||||
const content = `metadata:\n clusterName: tes`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -127,7 +127,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Array does not error on valid node', (done) => {
|
||||
it('Type Array does not error on valid node', done => {
|
||||
const content = `items:\n - apiVersion: v1`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -140,7 +140,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
});
|
||||
|
||||
describe('Test that validation DOES throw errors', function() {
|
||||
it('Error when theres no value for a node', (done) => {
|
||||
it('Error when theres no value for a node', done => {
|
||||
const content = `apiVersion:`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -150,7 +150,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (number)', (done) => {
|
||||
it('Error on incorrect value type (number)', done => {
|
||||
const content = `apiVersion: 1000`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -160,7 +160,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (boolean)', (done) => {
|
||||
it('Error on incorrect value type (boolean)', done => {
|
||||
const content = `apiVersion: False`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -170,7 +170,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (string)', (done) => {
|
||||
it('Error on incorrect value type (string)', done => {
|
||||
const content = `isNonResourceURL: hello_world`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -180,7 +180,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (object)', (done) => {
|
||||
it('Error on incorrect value type (object)', done => {
|
||||
const content = `apiVersion: v1\nkind: Pod\nmetadata:\n name: False`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -190,7 +190,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type in multiple yaml documents', (done) => {
|
||||
it('Error on incorrect value type in multiple yaml documents', done => {
|
||||
const content = `---\napiVersion: v1\n...\n---\napiVersion: False\n...`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -200,7 +200,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Property error message should be "Unexpected property {$property_name}" when property is not allowed ', (done) => {
|
||||
it('Property error message should be "Unexpected property {$property_name}" when property is not allowed ', done => {
|
||||
const content = `unknown_node: test`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
@ -220,7 +220,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -229,11 +229,11 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
const yDoc = parseYAML(testTextDocument.getText());
|
||||
return completionHelper(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
testTextDocument.positionAt(position)
|
||||
);
|
||||
}
|
||||
|
||||
it('Autocomplete on root node without word', (done) => {
|
||||
it('Autocomplete on root node without word', done => {
|
||||
const content = '';
|
||||
const completion = parseSetup(content, 0);
|
||||
completion
|
||||
|
|
@ -243,7 +243,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on root node with word', (done) => {
|
||||
it('Autocomplete on root node with word', done => {
|
||||
const content = 'api';
|
||||
const completion = parseSetup(content, 6);
|
||||
completion
|
||||
|
|
@ -253,7 +253,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on default value (without value content)', (done) => {
|
||||
it('Autocomplete on default value (without value content)', done => {
|
||||
const content = 'apiVersion: ';
|
||||
const completion = parseSetup(content, 10);
|
||||
completion
|
||||
|
|
@ -263,7 +263,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on default value (with value content)', (done) => {
|
||||
it('Autocomplete on default value (with value content)', done => {
|
||||
const content = 'apiVersion: v1\nkind: Bin';
|
||||
const completion = parseSetup(content, 19);
|
||||
completion
|
||||
|
|
@ -273,7 +273,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on boolean value (without value content)', (done) => {
|
||||
it('Autocomplete on boolean value (without value content)', done => {
|
||||
const content = 'isNonResourceURL: ';
|
||||
const completion = parseSetup(content, 18);
|
||||
completion
|
||||
|
|
@ -283,7 +283,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete on boolean value (with value content)', (done) => {
|
||||
it('Autocomplete on boolean value (with value content)', done => {
|
||||
const content = 'isNonResourceURL: fal';
|
||||
const completion = parseSetup(content, 21);
|
||||
completion
|
||||
|
|
@ -293,7 +293,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete key in middle of file', (done) => {
|
||||
it('Autocomplete key in middle of file', done => {
|
||||
const content = 'metadata:\n nam';
|
||||
const completion = parseSetup(content, 14);
|
||||
completion
|
||||
|
|
@ -303,7 +303,7 @@ xdescribe('Kubernetes Integration Tests', () => {
|
|||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Autocomplete key in middle of file 2', (done) => {
|
||||
it('Autocomplete key in middle of file 2', done => {
|
||||
const content = 'metadata:\n name: test\n cluster';
|
||||
const completion = parseSetup(content, 31);
|
||||
completion
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function toFsPath(str): string {
|
|||
}
|
||||
|
||||
const uri = toFsPath(
|
||||
path.join(__dirname, './fixtures/customMultipleSchemaSequences.json'),
|
||||
path.join(__dirname, './fixtures/customMultipleSchemaSequences.json')
|
||||
);
|
||||
const languageSettings: LanguageSettings = {
|
||||
schemas: [],
|
||||
|
|
@ -50,13 +50,13 @@ languageService.configure(languageSettings);
|
|||
|
||||
describe('Multiple Documents Validation Tests', () => {
|
||||
// Tests for validator
|
||||
describe('Multiple Documents Validation', function () {
|
||||
describe('Multiple Documents Validation', function() {
|
||||
function setup(content: string) {
|
||||
return TextDocument.create(
|
||||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ describe('Multiple Documents Validation Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
const yDoc = parseYAML(
|
||||
testTextDocument.getText(),
|
||||
languageSettings.customTags,
|
||||
languageSettings.customTags
|
||||
);
|
||||
return languageService.doValidation(testTextDocument, yDoc);
|
||||
}
|
||||
|
|
@ -75,11 +75,11 @@ describe('Multiple Documents Validation Tests', () => {
|
|||
return languageService.doHover(
|
||||
testTextDocument,
|
||||
testTextDocument.positionAt(position),
|
||||
jsonDocument,
|
||||
jsonDocument
|
||||
);
|
||||
}
|
||||
|
||||
it('Should validate multiple documents', (done) => {
|
||||
it('Should validate multiple documents', done => {
|
||||
const content = `
|
||||
name: jack
|
||||
age: 22
|
||||
|
|
@ -88,56 +88,56 @@ analytics: true
|
|||
`;
|
||||
const validator = validatorSetup(content);
|
||||
validator
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
assert.equal(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Should find errors in both documents', (done) => {
|
||||
it('Should find errors in both documents', done => {
|
||||
const content = `name1: jack
|
||||
age: asd
|
||||
---
|
||||
cwd: False`;
|
||||
const validator = validatorSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.equal(result.length, 3);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Should find errors in first document', (done) => {
|
||||
it('Should find errors in first document', done => {
|
||||
const content = `name: jack
|
||||
age: age
|
||||
---
|
||||
analytics: true`;
|
||||
const validator = validatorSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.equal(result.length, 1);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Should find errors in second document', (done) => {
|
||||
it('Should find errors in second document', done => {
|
||||
const content = `name: jack
|
||||
age: 22
|
||||
---
|
||||
cwd: False`;
|
||||
const validator = validatorSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.equal(result.length, 1);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Should hover in first document', (done) => {
|
||||
it('Should hover in first document', done => {
|
||||
const content = `name: jack\nage: 22\n---\ncwd: False`;
|
||||
const hover = hoverSetup(content, 1 + content.indexOf('age'));
|
||||
hover
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.contents.length, 0);
|
||||
assert.equal(result.contents[0], 'The age of this person');
|
||||
})
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const fixtureDocuments = {
|
|||
'http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json':
|
||||
'Microsoft.Compute.json',
|
||||
};
|
||||
const requestServiceMock = function (uri: string): Promise<string> {
|
||||
const requestServiceMock = function(uri: string): Promise<string> {
|
||||
if (uri.length && uri[uri.length - 1] === '#') {
|
||||
uri = uri.substr(0, uri.length - 1);
|
||||
}
|
||||
|
|
@ -48,10 +48,10 @@ const workspaceContext = {
|
|||
};
|
||||
|
||||
describe('JSON Schema', () => {
|
||||
test('Resolving $refs', function (testDone) {
|
||||
test('Resolving $refs', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
service.setSchemaContributions({
|
||||
schemas: {
|
||||
|
|
@ -74,7 +74,7 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getResolvedSchema('https://myschemastore/main')
|
||||
.then((solvedSchema) => {
|
||||
.then(solvedSchema => {
|
||||
assert.deepEqual(solvedSchema.schema.properties.child, {
|
||||
id: 'https://myschemastore/child',
|
||||
type: 'bool',
|
||||
|
|
@ -83,16 +83,16 @@ describe('JSON Schema', () => {
|
|||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Resolving $refs 2', function (testDone) {
|
||||
test('Resolving $refs 2', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
service.setSchemaContributions({
|
||||
schemas: {
|
||||
|
|
@ -121,7 +121,7 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getResolvedSchema('http://json.schemastore.org/swagger-2.0')
|
||||
.then((fs) => {
|
||||
.then(fs => {
|
||||
assert.deepEqual(fs.schema.properties.responseValue, {
|
||||
type: 'object',
|
||||
required: ['$ref'],
|
||||
|
|
@ -130,16 +130,16 @@ describe('JSON Schema', () => {
|
|||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Resolving $refs 3', function (testDone) {
|
||||
test('Resolving $refs 3', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
service.setSchemaContributions({
|
||||
schemas: {
|
||||
|
|
@ -172,7 +172,7 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getResolvedSchema('https://myschemastore/main/schema1.json')
|
||||
.then((fs) => {
|
||||
.then(fs => {
|
||||
assert.deepEqual(fs.schema.properties.p1, {
|
||||
type: 'string',
|
||||
enum: ['object'],
|
||||
|
|
@ -188,16 +188,16 @@ describe('JSON Schema', () => {
|
|||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('FileSchema', function (testDone) {
|
||||
test('FileSchema', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
|
||||
service.setSchemaContributions({
|
||||
|
|
@ -222,22 +222,22 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getResolvedSchema('main')
|
||||
.then((fs) => {
|
||||
.then(fs => {
|
||||
const section = fs.getSection(['child', 'grandchild']);
|
||||
assert.equal(section.description, 'Meaning of Life');
|
||||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Array FileSchema', function (testDone) {
|
||||
test('Array FileSchema', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
|
||||
service.setSchemaContributions({
|
||||
|
|
@ -265,22 +265,22 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getResolvedSchema('main')
|
||||
.then((fs) => {
|
||||
.then(fs => {
|
||||
const section = fs.getSection(['child', '0', 'grandchild']);
|
||||
assert.equal(section.description, 'Meaning of Life');
|
||||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Missing subschema', function (testDone) {
|
||||
test('Missing subschema', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
|
||||
service.setSchemaContributions({
|
||||
|
|
@ -299,22 +299,22 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getResolvedSchema('main')
|
||||
.then((fs) => {
|
||||
.then(fs => {
|
||||
const section = fs.getSection(['child', 'grandchild']);
|
||||
assert.strictEqual(section, null);
|
||||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Preloaded Schema', function (testDone) {
|
||||
test('Preloaded Schema', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
const id = 'https://myschemastore/test1';
|
||||
const schema: JsonSchema.JSONSchema = {
|
||||
|
|
@ -336,53 +336,53 @@ describe('JSON Schema', () => {
|
|||
|
||||
service
|
||||
.getSchemaForResource('test.json')
|
||||
.then((schema) => {
|
||||
.then(schema => {
|
||||
const section = schema.getSection(['child', 'grandchild']);
|
||||
assert.equal(section.description, 'Meaning of Life');
|
||||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Null Schema', function (testDone) {
|
||||
test('Null Schema', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
|
||||
service
|
||||
.getSchemaForResource('test.json')
|
||||
.then((schema) => {
|
||||
.then(schema => {
|
||||
assert.equal(schema, null);
|
||||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('Schema not found', function (testDone) {
|
||||
test('Schema not found', function(testDone) {
|
||||
const service = new SchemaService.JSONSchemaService(
|
||||
requestServiceMock,
|
||||
workspaceContext,
|
||||
workspaceContext
|
||||
);
|
||||
|
||||
service
|
||||
.loadSchema('test.json')
|
||||
.then((schema) => {
|
||||
.then(schema => {
|
||||
assert.notEqual(schema.errors.length, 0);
|
||||
})
|
||||
.then(
|
||||
() => testDone(),
|
||||
(error) => {
|
||||
error => {
|
||||
testDone(error);
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'SchemaDoesNotExist';
|
||||
|
|
@ -32,7 +32,7 @@ describe('Validation Tests', () => {
|
|||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -40,14 +40,14 @@ describe('Validation Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
const yDoc = parseYAML(
|
||||
testTextDocument.getText(),
|
||||
languageSettings.customTags,
|
||||
languageSettings.customTags
|
||||
);
|
||||
return languageService.doValidation(testTextDocument, yDoc);
|
||||
}
|
||||
|
||||
// Validating basic nodes
|
||||
describe('Test that validation throws error when schema is not found', function() {
|
||||
it('Basic test', (done) => {
|
||||
it('Basic test', done => {
|
||||
const content = `testing: true`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const assert = require('assert');
|
|||
const languageService = getLanguageService(
|
||||
schemaRequestService,
|
||||
workspaceContext,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
const uri = 'http://json.schemastore.org/bowerrc';
|
||||
|
|
@ -28,13 +28,13 @@ languageService.configure(languageSettings);
|
|||
|
||||
describe('Validation Tests', () => {
|
||||
// Tests for validator
|
||||
describe('Validation', function () {
|
||||
describe('Validation', function() {
|
||||
function setup(content: string) {
|
||||
return TextDocument.create(
|
||||
'file://~/Desktop/vscode-k8s/test.yaml',
|
||||
'yaml',
|
||||
0,
|
||||
content,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -42,154 +42,154 @@ describe('Validation Tests', () => {
|
|||
const testTextDocument = setup(content);
|
||||
const yDoc = parseYAML(
|
||||
testTextDocument.getText(),
|
||||
languageSettings.customTags,
|
||||
languageSettings.customTags
|
||||
);
|
||||
return languageService.doValidation(testTextDocument, yDoc);
|
||||
}
|
||||
|
||||
// Validating basic nodes
|
||||
describe('Test that validation does not throw errors', function () {
|
||||
it('Basic test', (done) => {
|
||||
describe('Test that validation does not throw errors', function() {
|
||||
it('Basic test', done => {
|
||||
const content = `analytics: true`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Test that boolean value in quotations is not interpreted as boolean i.e. it errors', (done) => {
|
||||
it('Test that boolean value in quotations is not interpreted as boolean i.e. it errors', done => {
|
||||
const content = `analytics: "no"`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Test that boolean value without quotations is valid', (done) => {
|
||||
it('Test that boolean value without quotations is valid', done => {
|
||||
const content = `analytics: no`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Test that boolean is valid when inside strings', (done) => {
|
||||
it('Test that boolean is valid when inside strings', done => {
|
||||
const content = `cwd: "no"`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Test that boolean is invalid when no strings present and schema wants string', (done) => {
|
||||
it('Test that boolean is invalid when no strings present and schema wants string', done => {
|
||||
const content = `cwd: no`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Basic test', (done) => {
|
||||
it('Basic test', done => {
|
||||
const content = `analytics: true`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Basic test on nodes with children', (done) => {
|
||||
it('Basic test on nodes with children', done => {
|
||||
const content = `scripts:\n preinstall: test1\n postinstall: test2`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Advanced test on nodes with children', (done) => {
|
||||
it('Advanced test on nodes with children', done => {
|
||||
const content = `analytics: true\ncwd: this\nscripts:\n preinstall: test1\n postinstall: test2`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type string validates under children', (done) => {
|
||||
it('Type string validates under children', done => {
|
||||
const content = `registry:\n register: http://test_url.com`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Include with value should not error', (done) => {
|
||||
it('Include with value should not error', done => {
|
||||
const content = `customize: !include customize.yaml`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Null scalar value should be treated as null', (done) => {
|
||||
it('Null scalar value should be treated as null', done => {
|
||||
const content = `cwd: Null`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(1);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Anchor should not not error', (done) => {
|
||||
it('Anchor should not not error', done => {
|
||||
const content = `default: &DEFAULT\n name: Anchor\nanchor_test:\n <<: *DEFAULT`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Anchor with multiple references should not not error', (done) => {
|
||||
it('Anchor with multiple references should not not error', done => {
|
||||
const content = `default: &DEFAULT\n name: Anchor\nanchor_test:\n <<: *DEFAULT\nanchor_test2:\n <<: *DEFAULT`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Multiple Anchor in array of references should not not error', (done) => {
|
||||
it('Multiple Anchor in array of references should not not error', done => {
|
||||
const content = `default: &DEFAULT\n name: Anchor\ncustomname: &CUSTOMNAME\n custom_name: Anchor\nanchor_test:\n <<: [*DEFAULT, *CUSTOMNAME]`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Multiple Anchors being referenced in same level at same time', (done) => {
|
||||
it('Multiple Anchors being referenced in same level at same time', done => {
|
||||
const content = `
|
||||
default: &DEFAULT
|
||||
name: Anchor
|
||||
|
|
@ -201,87 +201,87 @@ describe('Validation Tests', () => {
|
|||
`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Custom Tags without type', (done) => {
|
||||
it('Custom Tags without type', done => {
|
||||
const content = `analytics: !Test false`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Custom Tags with type', (done) => {
|
||||
it('Custom Tags with type', done => {
|
||||
const content = `resolvers: !Ref\n - test`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
describe('Type tests', function () {
|
||||
it('Type String does not error on valid node', (done) => {
|
||||
describe('Type tests', function() {
|
||||
it('Type String does not error on valid node', done => {
|
||||
const content = `cwd: this`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Boolean does not error on valid node', (done) => {
|
||||
it('Type Boolean does not error on valid node', done => {
|
||||
const content = `analytics: true`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Number does not error on valid node', (done) => {
|
||||
it('Type Number does not error on valid node', done => {
|
||||
const content = `timeout: 60000`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Object does not error on valid node', (done) => {
|
||||
it('Type Object does not error on valid node', done => {
|
||||
const content = `registry:\n search: http://test_url.com`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Type Array does not error on valid node', (done) => {
|
||||
it('Type Array does not error on valid node', done => {
|
||||
const content = `resolvers:\n - test\n - test\n - test`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Do not error when there are multiple types in schema and theyre valid', (done) => {
|
||||
it('Do not error when there are multiple types in schema and theyre valid', done => {
|
||||
const content = `license: MIT`;
|
||||
const validator = parseSetup(content);
|
||||
validator.then(function (result) {
|
||||
validator.then(function(result) {
|
||||
expect(result.length).toEqual(0);
|
||||
});
|
||||
done();
|
||||
|
|
@ -289,82 +289,82 @@ describe('Validation Tests', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Test that validation DOES throw errors', function () {
|
||||
it('Error when theres a finished untyped item', (done) => {
|
||||
describe('Test that validation DOES throw errors', function() {
|
||||
it('Error when theres a finished untyped item', done => {
|
||||
const content = `cwd: hello\nan`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error when theres no value for a node', (done) => {
|
||||
it('Error when theres no value for a node', done => {
|
||||
const content = `cwd:`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (number)', (done) => {
|
||||
it('Error on incorrect value type (number)', done => {
|
||||
const content = `cwd: 100000`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (boolean)', (done) => {
|
||||
it('Error on incorrect value type (boolean)', done => {
|
||||
const content = `cwd: False`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (string)', (done) => {
|
||||
it('Error on incorrect value type (string)', done => {
|
||||
const content = `analytics: hello`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (object)', (done) => {
|
||||
it('Error on incorrect value type (object)', done => {
|
||||
const content = `scripts: test`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Error on incorrect value type (array)', (done) => {
|
||||
it('Error on incorrect value type (array)', done => {
|
||||
const content = `resolvers: test`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
assert.notEqual(result.length, 0);
|
||||
})
|
||||
.then(done, done);
|
||||
});
|
||||
|
||||
it('Include without value should error', (done) => {
|
||||
it('Include without value should error', done => {
|
||||
const content = `customize: !include`;
|
||||
const validator = parseSetup(content);
|
||||
validator
|
||||
.then(function (result) {
|
||||
.then(function(result) {
|
||||
expect(result.length).toEqual(1);
|
||||
})
|
||||
.then(done, done);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import URI from '../src/languageservice/utils/uri';
|
|||
|
||||
namespace VSCodeContentRequest {
|
||||
export const type: RequestType<{}, {}, {}, {}> = new RequestType(
|
||||
'vscode/content',
|
||||
'vscode/content'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ let connection: IConnection = null;
|
|||
if (process.argv.indexOf('--stdio') === -1) {
|
||||
connection = createConnection(
|
||||
new IPCMessageReader(process),
|
||||
new IPCMessageWriter(process),
|
||||
new IPCMessageWriter(process)
|
||||
);
|
||||
} else {
|
||||
connection = createConnection();
|
||||
|
|
@ -50,7 +50,7 @@ connection.onInitialize(
|
|||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export let workspaceContext = {
|
||||
|
|
@ -69,24 +69,24 @@ export let schemaRequestService = (uri: string): Thenable<string> => {
|
|||
});
|
||||
} else if (Strings.startsWith(uri, 'vscode://')) {
|
||||
return connection.sendRequest(VSCodeContentRequest.type, uri).then(
|
||||
(responseText) => {
|
||||
responseText => {
|
||||
return responseText;
|
||||
},
|
||||
(error) => {
|
||||
error => {
|
||||
return error.message;
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
return xhr({ url: uri, followRedirects: 5 }).then(
|
||||
(response) => {
|
||||
response => {
|
||||
return response.responseText;
|
||||
},
|
||||
(error: XHRResponse) => {
|
||||
return Promise.reject(
|
||||
error.responseText ||
|
||||
getErrorStatusDescription(error.status) ||
|
||||
error.toString(),
|
||||
error.toString()
|
||||
);
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ describe('URI Tests', () => {
|
|||
'www.foo.com',
|
||||
'/bar.html',
|
||||
'name=hello',
|
||||
'123',
|
||||
'123'
|
||||
);
|
||||
assert.equal(result.authority, 'www.foo.com');
|
||||
assert.equal(result.fragment, '123');
|
||||
|
|
@ -69,14 +69,14 @@ describe('URI Tests', () => {
|
|||
describe('URI toString', function() {
|
||||
it('toString with encoding', () => {
|
||||
const result = URI.parse(
|
||||
'http://www.foo.com:8080/bar.html?name=hello#123',
|
||||
'http://www.foo.com:8080/bar.html?name=hello#123'
|
||||
).toString();
|
||||
assert.equal('http://www.foo.com:8080/bar.html?name%3Dhello#123', result);
|
||||
});
|
||||
|
||||
it('toString without encoding', () => {
|
||||
const result = URI.parse(
|
||||
'http://www.foo.com/bar.html?name=hello#123',
|
||||
'http://www.foo.com/bar.html?name=hello#123'
|
||||
).toString(true);
|
||||
assert.equal('http://www.foo.com/bar.html?name=hello#123', result);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue