Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ suite('JSON Parser', () => {
return jsonDoc.validate(textDoc, schema, undefined, draft);
}

function validateWithInferredDraft(jsonDoc: JSONDocument, textDoc: TextDocument, schema: JSONSchema) {
return jsonDoc.validate(textDoc, schema);
}

function assertObject(node: ASTNode, expectedProperties: string[]) {
assert.equal(node.type, 'object');
assert.equal((<ObjectASTNode>node).properties.length, expectedProperties.length);
Expand Down Expand Up @@ -2219,6 +2223,11 @@ suite('JSON Parser', () => {
const semanticErrors = validate2(jsonDoc, textDoc, schema);
assert.strictEqual(semanticErrors!.length, 1);
}
{
const { textDoc, jsonDoc } = toDocument('{"a":true}');
const semanticErrors = validateWithInferredDraft(jsonDoc, textDoc, schema);
assert.strictEqual(semanticErrors!.length, 1);
}
schema = {
"type": "object",

Expand Down Expand Up @@ -2299,6 +2308,11 @@ suite('JSON Parser', () => {
const semanticErrors = validate2(jsonDoc, textDoc, schema);
assert.strictEqual(semanticErrors!.length, 1);
}
{
const { textDoc, jsonDoc } = toDocument('{"a":true, "b": "string"}');
const semanticErrors = validateWithInferredDraft(jsonDoc, textDoc, schema);
assert.strictEqual(semanticErrors!.length, 1);
}
schema = {
"type": "object",

Expand Down