aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitmodules3
-rw-r--r--src/nodejs/package.json3
-rw-r--r--src/nodejs/tests/async_basis_test.js26
m---------src/nodejs/tests/node-async-testing0
-rw-r--r--src/nodejs/tests/pathparsing.js113
-rw-r--r--src/nodejs/tests/urlToResObj.js61
6 files changed, 145 insertions, 61 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..4b7b098
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/nodejs/tests/node-async-testing"]
+ path = src/nodejs/tests/node-async-testing
+ url = https://github.com/bentomas/node-async-testing.git
diff --git a/src/nodejs/package.json b/src/nodejs/package.json
index 97db4eb..92b4c3c 100644
--- a/src/nodejs/package.json
+++ b/src/nodejs/package.json
@@ -10,4 +10,7 @@
, "log4js" : "*"
, "opts" : "*"
}
+, "dependencies" :
+ { "async_testing" : "*"
+ }
}
diff --git a/src/nodejs/tests/async_basis_test.js b/src/nodejs/tests/async_basis_test.js
new file mode 100644
index 0000000..47062e3
--- /dev/null
+++ b/src/nodejs/tests/async_basis_test.js
@@ -0,0 +1,26 @@
+if (module == require.main) {
+ return require('./node-async-testing/lib/async_testing').run(process.ARGV);
+}
+
+module.exports = {
+ 'test A': function(test) {
+ test.ok(true);
+ test.finish();
+ },
+
+ 'test B': function(test) {
+ test.ok(true);
+ test.finish();
+ },
+
+ 'test C': function(test) {
+ test.ok(true);
+ test.finish();
+ },
+
+ 'test D': function(test) {
+ test.ok(true);
+ test.finish();
+ }
+};
+
diff --git a/src/nodejs/tests/node-async-testing b/src/nodejs/tests/node-async-testing
new file mode 160000
+Subproject a87f89d3f2437133364e1edc059a71a89520835
diff --git a/src/nodejs/tests/pathparsing.js b/src/nodejs/tests/pathparsing.js
new file mode 100644
index 0000000..e1a20f5
--- /dev/null
+++ b/src/nodejs/tests/pathparsing.js
@@ -0,0 +1,113 @@
+if (module == require.main) {
+ async_testing = require('./node-async-testing/lib/async_testing');
+ return async_testing.run(process.ARGV);
+}
+var assert = require('assert');
+
+var test = require('../parse.js');
+//TODO function does not exist yet
+var toTest = test.urlToXpathObj;
+
+// TODO invalid object eg not (node, way, relation)
+
+module.exports =
+
+ // simple tests
+ { 'simple node': function(test) {
+ test.ok(true);
+ var simpleNodeString = "/node";
+ var expected = { object: "node" };
+ assert.deepEqual(toTest(simpleNodeString), expected);
+ test.finish();
+ }
+ , 'simple way': function(test) {
+ test.ok(true);
+ var simpleWayString = "/way";
+ var expected = { object: "way" };
+ assert.deepEqual(toTest(simpleWayString), expected);
+ test.finish();
+ }
+ , 'simple relation': function(test) {
+ test.ok(true);
+ var simpleRelationString = "/relation";
+ var expected = { object: "relation" };
+ assert.deepEqual(toTest(simpleRelationString), expected);
+ test.finish();
+ }
+
+ // simple tests with trailing /
+ , 'simple node string with trailing /': function(test) {
+ test.ok(true);
+ var simpleNodeStringTrail = "/node/";
+ var expected = { object: "node" };
+ assert.deepEqual(toTest(simpleNodeStringTrail), expected);
+ test.finish();
+ }
+ , 'simple way string with trailing /': function(test) {
+ test.ok(true);
+ var simpleWayStringTrail = "/way/";
+ var expected = { object: "way" };
+ assert.deepEqual(toTest(simpleWayStringTrail), expected);
+ test.finish();
+ }
+ , 'simple relation string with trailing /': function(test) {
+ test.ok(true);
+ var simpleRelationStringTrail = "/relation/";
+ var expected = { object: "relation" };
+ assert.deepEqual(toTest(simpleRelationStringTrail), expectedi);
+ test.finish();
+ }
+
+ // bbox tests
+ , 'simple bbox test': function(test) {
+ test.ok(true);
+ var nodeWithBbox = "/node[bbox=0,51.5,0.25,51.75]";
+ var expected = { object: "node", bbox: {left:0, bottom:51.5, right:0.25, top:51.75} };
+ assert.deepEqual(toTest(nodeWithBbox), expected);
+ test.finish();
+ }
+
+ // tag tests
+ , 'simple tag': function(test) {
+ test.ok(true);
+ var nodeWithSimpleTag = "/node[key=value]";
+ var expected = { object: "node", tag: { key:["key"], value:["value"]}};
+ assert.deepEqual(toTest(nodeWithSimpleTag), expected);
+ test.finish();
+ }
+ , 'tag with two values': function(test) {
+ test.ok(true);
+ var nodeWithTwoValues = "/node[tag=foo|bar]";
+ var expected = { object: "node", tag: { key:["key"], value:["foo", "bar"]}};
+ assert.deepEqual(toTest(nodeWithTwoValues), expected);
+ test.finish();
+ }
+ , 'tag with two keys': function(test) {
+ test.ok(true);
+ var nodeWithTwoKeys = "/node[foo,bar=value]";
+ var expected = { object: "node", tag: { key:["foo", "bar"], value:["value"]}};
+ assert.deepEqual(toTest(nodeWithTwoKeys), expected);
+ test.finish();
+ }
+ , 'tags with cross product': function(test) {
+ test.ok(true);
+ var tagCrossProduct = "/node[key1,key2=value1,value2]";
+ var expected = { object: "node", tag: {key:["key1", "key2"], value:["value1", "value2"]}};
+ assert.deepEqual(toTest(tagCrossProduct), expected);
+ test.finish();
+ }
+ , 'bbox before tag': function(test) {
+ test.ok(true);
+ var nodeBboxTag = "/node[bbox=0,0,0,0][key=value]";
+ var expected = { object: "node", bbox: {left:0,bottom:0,right:0,top:0}, tag: {key:["key"], value:["value"]}};
+ assert.deepEqual(toTest(nodeBboxTag), expected);
+ test.finish();
+ }
+ , 'tag before bbox': function(test) {
+ test.ok(true);
+ var nodeTagBbox = "/node[bbox=0,0,0,0][key=value]";
+ var expected = { object: "node", bbox: {left:0,bottom:0,right:0,top:0}, tag: {key:["key"], value:["value"]}};
+ assert.deepEqual(toTest(nodeTagBbox), expected);
+ test.finish();
+ }
+};
diff --git a/src/nodejs/tests/urlToResObj.js b/src/nodejs/tests/urlToResObj.js
deleted file mode 100644
index a29fb3f..0000000
--- a/src/nodejs/tests/urlToResObj.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var assert = require('assert');
-var test = require('../parse.js');
-//TODO function does not exist yet
-var toTest = test.urlToXpathObj;
-
-
-// test all simple objects { node, way, relation }
-
-var simpleNodeString = "/node";
-var expected = { object: "node" };
-assert.equal(toTest(simpleNodeString), expected);
-
-var simpleNodeStringiTrail = "/node/";
-var expected = { object: "node" };
-assert.equal(toTest(simpleNodeStringTrail), expected);
-
-var simpleWayString = "/way";
-var expected = { object: "way" };
-assert.equal(toTest(simpleWayString), expected);
-
-var simpleWayStringTrail = "/way/";
-var expected = { object: "way" };
-assert.equal(toTest(simpleWayStringTrail), expected);
-
-var simpleRelationString = "/relation";
-var expected = { object: "relation" };
-assert.equal(toTest(simpleRelationString), expected);
-
-var simpleRelationStringTrail = "/relation/";
-var expected = { object: "relation" };
-assert.equal(toTest(simpleRelationStringTrail), expectedi);
-
-// TODO invalid object eg not (node, way, relation)
-
-var nodeWithBbox = "/node[bbox=0,51.5,0.25,51.75]";
-var expected = { object: "node", bbox: {left:0, bottom:51.5, right:0.25, top:51.75} };
-assert.equal(toTest(nodeWithBbox), expected);
-
-var nodeWithSimpleTag = "/node[key=value]";
-var expected = { object: "node", tag: { key:["key"], value:["value"]}};
-assert.equals(toTest(nodeWithSimpleTag), expected);
-
-var nodeWithTwoValues = "/node[tag=foo|bar]";
-var expected = { object: "node", tag: { key:["key"], value:["foo", "bar"]}};
-assert.equals(toTest(nodeWithTwoValues), expected);
-
-var nodeWithTwoKeys = "/node[foo,bar=value]";
-var expected = { object: "node", tag: { key:["foo", "bar"], value:["value"]}};
-assert.equals(toTest(nodeWithTwoKeys), expected);
-
-var tagCrossProduct = "/node[key1,key2=value1,value2]";
-var expected = { object: "node", tag: {key:["key1", "key2"], value:["value1", "value2"]}};
-assert.equals(toTest(tagCrossProduct), expected);
-
-var nodeBboxTag = "/node[bbox=0,0,0,0][key=value]";
-var nodeTagBbox = "/node[bbox=0,0,0,0][key=value]";
-var expected = { object: "node", bbox: {left:0,bottom:0,right:0,top:0}, tag: {key:["key"], value:["value"]}};
-assert.equals(toTest(nodeBboxTag), expected);
-assert.equals(toTest(nodeTagBbox), expected);
-
-