Permalink
Browse files

add failing test (complex keys)

  • Loading branch information...
1 parent 909456c commit fd6670ee9c4b9b6ab42b19c224cc05f7e5130a33 @benjamin-atkin benjamin-atkin committed Jul 25, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 test.js
View
15 test.js
@@ -31,4 +31,19 @@ assert.equal(jsonpointer.get(obj, "/d/e/0/a"), 4);
assert.equal(jsonpointer.get(obj, "/d/e/1/b"), 5);
assert.equal(jsonpointer.get(obj, "/d/e/2/c"), 6);
+var complexKeys = {
+ "a/b": {
+ c: 1
+ },
+ d: {
+ "e/f": 2
+ }
+}
+
+assert.equal(jsonpointer.get(complexKeys, "/a%2Fb/c"), 1);
+assert.equal(jsonpointer.get(complexKeys, "/d/e%2Ff"), 2);
+assert.throws(function() {
+ assert.equal(jsonpointer.get(complexKeys, "/a/b/c"), 1);
+});
+
console.log("All tests pass.");

0 comments on commit fd6670e

Please sign in to comment.