Skip to content

Commit

Permalink
Add unit tests for 'vg.accessor'.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Apr 12, 2013
1 parent e77b231 commit d27bce0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/_package-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,25 @@ suite.addBatch({
['a.b.c', 'a2.b2', 'a3.b3.c3' ]);
}
},
'accessor': {
'should return null argument': function (vg) {
assert.isNull(vg.accessor(null));
},
'should return function argument': function (vg) {
var f = function () {
};
assert.strictEqual(vg.accessor(f), f);
},
'should return accessor function for property of simple String argument': function (vg) {
assert.equal(vg.accessor('test')({ 'test': 'value'}), 'value');
},
'should return accessor function that resolves property paths for String arguments with .': function (vg) {
assert.equal(vg.accessor('a\\.b.c.d')({ 'a.b': { 'c': { 'd': 'value'}}}), 'value');
},
'should return accessor function for number arguments': function (vg) {
assert.equal(vg.accessor(1)(['a', 'b']), 'b');
}
},
'array': {
'array(null) should return an empty array': function (vg) {
assert.deepEqual(vg.array(null), []);
Expand Down

0 comments on commit d27bce0

Please sign in to comment.