Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/test/data/extensions/json_schema_test.js

Issue 39113003: Docserver: Display enum value descriptions in API docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var AssertTrue = requireNative('assert').AssertTrue; 5 var AssertTrue = requireNative('assert').AssertTrue;
6 var JSONSchemaValidator = require('json_schema').JSONSchemaValidator; 6 var JSONSchemaValidator = require('json_schema').JSONSchemaValidator;
7 var LOG = requireNative('logging').LOG; 7 var LOG = requireNative('logging').LOG;
8 8
9 function assertValid(type, instance, schema, types) { 9 function assertValid(type, instance, schema, types) {
10 var validator = new JSONSchemaValidator(); 10 var validator = new JSONSchemaValidator();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 assertValid("", instance, schema); 131 assertValid("", instance, schema);
132 132
133 instance[0].id = 0; 133 instance[0].id = 0;
134 assertNotValid("", instance, schema, 134 assertNotValid("", instance, schema,
135 [formatError("numberMinValue", 135 [formatError("numberMinValue",
136 [schema.items[0].properties.id.minimum])]); 136 [schema.items[0].properties.id.minimum])]);
137 } 137 }
138 138
139 function testEnum() { 139 function testEnum() {
140 var schema = { 140 var schema = {
141 enum: ["foo", 42, false] 141 enum: [{"name": "foo"}, 42, false]
142 }; 142 };
143 143
144 assertValid("", "foo", schema); 144 assertValid("", "foo", schema);
145 assertValid("", 42, schema); 145 assertValid("", 42, schema);
146 assertValid("", false, schema); 146 assertValid("", false, schema);
147 var enum_values = ["foo", 42, false];
147 assertNotValid("", "42", schema, [formatError("invalidEnum", 148 assertNotValid("", "42", schema, [formatError("invalidEnum",
148 [schema.enum.join(", ")])]); 149 [enum_values.join(", ")])]);
149 assertNotValid("", null, schema, [formatError("invalidEnum", 150 assertNotValid("", null, schema, [formatError("invalidEnum",
150 [schema.enum.join(", ")])]); 151 [enum_values.join(", ")])]);
151 } 152 }
152 153
153 function testChoices() { 154 function testChoices() {
154 var schema = { 155 var schema = {
155 choices: [ 156 choices: [
156 { type: "null" }, 157 { type: "null" },
157 { type: "undefined" }, 158 { type: "undefined" },
158 { type: "integer", minimum:42, maximum:42 }, 159 { type: "integer", minimum:42, maximum:42 },
159 { type: "object", properties: { foo: { type: "string" } } } 160 { type: "object", properties: { foo: { type: "string" } } }
160 ] 161 ]
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 exports.testArrayNonTuple = testArrayNonTuple; 660 exports.testArrayNonTuple = testArrayNonTuple;
660 exports.testString = testString; 661 exports.testString = testString;
661 exports.testNumber = testNumber; 662 exports.testNumber = testNumber;
662 exports.testIntegerBounds = testIntegerBounds; 663 exports.testIntegerBounds = testIntegerBounds;
663 exports.testType = testType; 664 exports.testType = testType;
664 exports.testTypeReference = testTypeReference; 665 exports.testTypeReference = testTypeReference;
665 exports.testGetAllTypesForSchema = testGetAllTypesForSchema; 666 exports.testGetAllTypesForSchema = testGetAllTypesForSchema;
666 exports.testIsValidSchemaType = testIsValidSchemaType; 667 exports.testIsValidSchemaType = testIsValidSchemaType;
667 exports.testCheckSchemaOverlap = testCheckSchemaOverlap; 668 exports.testCheckSchemaOverlap = testCheckSchemaOverlap;
668 exports.testInstanceOf = testInstanceOf; 669 exports.testInstanceOf = testInstanceOf;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698