Commit 463bbc9b authored by Boris Kocherov's avatar Boris Kocherov

tests: use replaceAll in tests for replace urls

parent 5ec49b94
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
QUnit.config.autostart = false; QUnit.config.autostart = false;
function replaceAll(str, searchStr, replaceStr) {
searchStr = searchStr.replace(/[\-\/\\\^$*+?.()|\[\]{}]/g, '\\$&');
return str.replace(new RegExp(searchStr, 'gi'), replaceStr);
}
function downloadJSON(url) { function downloadJSON(url) {
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
...@@ -263,7 +268,7 @@ ...@@ -263,7 +268,7 @@
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(replaceAll(JSON.stringify(m.schema), "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];
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
(function (window, rJS, jIO) { (function (window, rJS, jIO) {
"use strict"; "use strict";
function replaceAll(str, searchStr, replaceStr) {
searchStr = searchStr.replace(/[\-\/\\\^$*+?.()|\[\]{}]/g, '\\$&');
return str.replace(new RegExp(searchStr, 'gi'), replaceStr);
}
function downloadJSON(url) { function downloadJSON(url) {
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
...@@ -104,7 +109,7 @@ ...@@ -104,7 +109,7 @@
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/", schema = JSON.parse(replaceAll(JSON.stringify(m.schema), "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];
......
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