summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-07 16:09:23 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-07 16:12:43 +0200
commit1d3a63d75fce583032333a9d088a0d6d6569f58d (patch)
tree23805370570fe29e05706e55d3ce4d8d04facb58 /test
parent8c53aec1ce4d34cc245a755498c068a15ca99997 (diff)
downloadcollection-json-explorer-1d3a63d75fce583032333a9d088a0d6d6569f58d.tar.gz
collection-json-explorer-1d3a63d75fce583032333a9d088a0d6d6569f58d.tar.bz2
collection-json-explorer-1d3a63d75fce583032333a9d088a0d6d6569f58d.tar.xz
collection-json-explorer-1d3a63d75fce583032333a9d088a0d6d6569f58d.zip
o Splitting 'hrefs' so the user can click on any path segment.
Diffstat (limited to 'test')
-rw-r--r--test/split.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/split.js b/test/split.js
new file mode 100644
index 0000000..4bf8277
--- /dev/null
+++ b/test/split.js
@@ -0,0 +1,44 @@
+var assert = require('assert')
+ , util = require('util')
+ , routes = require('../routes/index.js');
+
+function assertSplit(url, expected) {
+ var actual = routes.split(url);
+ // console.log('actual ', util.inspect(actual));
+ // console.log('expected', util.inspect(expected));
+ assert.deepEqual(actual, expected);
+}
+
+describe('routes.split', function() {
+ it('http://localhost:123/', function() {
+ assertSplit('http://localhost:123/', [
+ ['http://localhost:123','http://localhost:123']
+ ]);
+ });
+ it('http://localhost:123/foo', function() {
+ assertSplit('http://localhost:123/foo', [
+ ['http://localhost:123','http://localhost:123'],
+ ['/foo','http://localhost:123/foo'],
+ ]);
+ });
+ it('http://localhost:123/foo/', function() {
+ assertSplit('http://localhost:123/foo/', [
+ ['http://localhost:123','http://localhost:123'],
+ ['/foo','http://localhost:123/foo'],
+ ]);
+ });
+ it('http://localhost:123/a?x=1&y=2', function() {
+ assertSplit('http://localhost:123/a?x=1&y=2', [
+ ['http://localhost:123','http://localhost:123'],
+ ['/a','http://localhost:123/a'],
+ ['?x=1&y=2','http://localhost:123/a?x=1&y=2']
+ ]);
+ });
+ it('http://localhost:123/a/?x=1&y=2', function() {
+ assertSplit('http://localhost:123/a/?x=1&y=2', [
+ ['http://localhost:123','http://localhost:123'],
+ ['/a','http://localhost:123/a'],
+ ['/?x=1&y=2','http://localhost:123/a/?x=1&y=2']
+ ]);
+ });
+});