Skip to content

Commit

Permalink
Adds test for issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelstofer committed Sep 8, 2013
1 parent 9f02819 commit 29497f3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ describe('json-api', function () {
pointers[0].should.equal('/users/0/name');
pointers[1].should.equal('/users/1/name');
});

it('should work with other arrays', function () {
var obj = {
bla : {
bli : [4, 5, 6]
}
},
dict = pointer.dict(obj);
dict['/bla/bli/0'].should.equal(4);
dict['/bla/bli/1'].should.equal(5);
dict['/bla/bli/2'].should.equal(6);
});
});

describe('#has', function () {
Expand Down Expand Up @@ -142,6 +154,11 @@ describe('json-api', function () {
});

describe('#parse', function () {
it('should work with top level path', function () {
pointer.parse('/bla')[0].should.equal('bla');
pointer.parse('/bla').length.should.equal(1);
});

it('should convert a pointer to an array of reference tokens', function () {
pointer.parse('/hello~0bla/test~1bla')[0].should.equal('hello~bla');
pointer.parse('/hello~0bla/test~1bla')[1].should.equal('test/bla');
Expand Down

0 comments on commit 29497f3

Please sign in to comment.