Commit bb373146 authored by Boris Kocherov's avatar Boris Kocherov

tests: use schema instead schema_url option when rendered

parent e9ac0240
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
settings = test_settings[test_id] || {}, settings = test_settings[test_id] || {},
key = "foo_key", key = "foo_key",
schema_orig; schema_orig;
if (schema) { if (schema !== undefined) {
schema_orig = JSON.parse(JSON.stringify(schema)); schema_orig = JSON.parse(JSON.stringify(schema));
} }
if (settings.invert_valid) { if (settings.invert_valid) {
...@@ -182,12 +182,17 @@ ...@@ -182,12 +182,17 @@
} }
}) })
.push(function (g) { .push(function (g) {
gadget = g; var opt = {
return gadget.render({
key: key, key: key,
schema_url: schema_url,
value: value value: value
}); };
gadget = g;
if (schema !== undefined) {
opt.schema = schema;
} else {
opt.schema_url = schema_url;
}
return gadget.render(opt);
}) })
.push(function (element) { .push(function (element) {
assert.ok(element, "gadget rendered"); assert.ok(element, "gadget rendered");
...@@ -195,7 +200,7 @@ ...@@ -195,7 +200,7 @@
}) })
.push(function (json_document) { .push(function (json_document) {
var returned_value; var returned_value;
if (schema_orig) { if (schema_orig !== undefined) {
// if schema used check side error // if schema used check side error
// if schema_url used we can not check schema_side_error // if schema_url used we can not check schema_side_error
// because gadget himself download schema // because gadget himself download schema
...@@ -248,7 +253,7 @@ ...@@ -248,7 +253,7 @@
z, z,
m, m,
t, t,
// schema, schema,
skip_file, skip_file,
skip_module, skip_module,
create_test; create_test;
...@@ -258,8 +263,8 @@ ...@@ -258,8 +263,8 @@
m = list[i][k]; m = list[i][k];
skip_module = skip_modules.indexOf(m.description) >= 0; skip_module = skip_modules.indexOf(m.description) >= 0;
module(m.description); module(m.description);
// schema = JSON.parse(JSON.stringify(m.schema).replace("http://localhost:1234/", schema = JSON.parse(JSON.stringify(m.schema).replace("http://localhost:1234/",
// "http://localhost:9000/node_modules/json-schema-test-suite/remotes/")); "http://localhost:9000/node_modules/json-schema-test-suite/remotes/"));
for (z = 0; z < m.tests.length; z += 1) { for (z = 0; z < m.tests.length; z += 1) {
t = m.tests[z]; t = m.tests[z];
if (todo_tests.indexOf(m.description + ': ' + t.description) >= 0) { if (todo_tests.indexOf(m.description + ': ' + t.description) >= 0) {
...@@ -271,7 +276,7 @@ ...@@ -271,7 +276,7 @@
} }
create_test(t.description, create_callback( create_test(t.description, create_callback(
null, //schema schema,
url_list[i] + '#/' + k + '/schema', url_list[i] + '#/' + k + '/schema',
t.data, t.data,
t.valid t.valid
......
...@@ -65,17 +65,20 @@ ...@@ -65,17 +65,20 @@
k, k,
z, z,
m, m,
schema,
t; t;
for (i = 0; i < list.length; i += 1) { for (i = 0; i < list.length; i += 1) {
for (k = 0; k < list[i].length; k += 1) { for (k = 0; k < list[i].length; k += 1) {
m = list[i][k]; m = list[i][k];
g.props.schemas.push(m.description); g.props.schemas.push(m.description);
g.props.documents[m.description] = []; g.props.documents[m.description] = [];
schema = JSON.parse(JSON.stringify(m.schema).replace("http://localhost:1234/",
"http://localhost:9000/node_modules/json-schema-test-suite/remotes/"));
for (z = 0; z < m.tests.length; z += 1) { for (z = 0; z < m.tests.length; z += 1) {
t = m.tests[z]; t = m.tests[z];
g.props.documents[m.description].push(t.description); g.props.documents[m.description].push(t.description);
g.props.test_data[m.description + ': ' + t.description] = { g.props.test_data[m.description + ': ' + t.description] = {
schema: m.schema, schema: schema,
schema_url: url_list[i] + '#/' + k + '/schema', schema_url: url_list[i] + '#/' + k + '/schema',
data: t.data, data: t.data,
status: t.valid status: t.valid
...@@ -128,7 +131,7 @@ ...@@ -128,7 +131,7 @@
console.log(test.schema); console.log(test.schema);
console.log(test.data); console.log(test.data);
return gadget.changeState({ return gadget.changeState({
schema_url: test.schema_url, schema: test.schema,
json_document: test.data json_document: test.data
}); });
} }
...@@ -154,6 +157,7 @@ ...@@ -154,6 +157,7 @@
.push(function (form_view) { .push(function (form_view) {
return form_view.render({ return form_view.render({
value: g.state.json_document, value: g.state.json_document,
schema: g.state.schema,
schema_url: g.state.schema_url schema_url: g.state.schema_url
}) })
.push(function () { .push(function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment