Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanAnnable committed Jan 19, 2017
1 parent d01d6b4 commit 5d873ae
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/suites/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,45 @@ describe('Cursor API', function() {
}, /solve/);
});

it('should support setting non-enumerable properties', function() {
const tree = new Baobab(Object.create({}, {
id: {value: 2, writable: true, enumerable: true},
hello: {value: 'world', writable: true, enumerable: false}
})),
cursor = tree.select('hello');

cursor.set('universe');
assert.equal(cursor.get(), 'universe');
assert.equal(Object.getOwnPropertyDescriptor(tree.get(), 'id').enumerable, true);
assert.equal(Object.getOwnPropertyDescriptor(tree.get(), 'hello').enumerable, false);
});

it('should support setting deep non-enumerable properties', function() {
const tree = new Baobab(Object.create({}, {
id: {
value: 2,
writable: true,
enumerable: true
},
one: {
value: Object.create({}, {two: {
value: 'three',
writable: true,
enumerable: false
}}),
writable: true,
enumerable: false,
}
})),
cursor = tree.select(['one', 'two']);

cursor.set('four');
assert.equal(tree.get(['one', 'two']), 'four');
assert.equal(Object.getOwnPropertyDescriptor(tree.get(), 'id').enumerable, true);
assert.equal(Object.getOwnPropertyDescriptor(tree.get(), 'one').enumerable, false);
assert.equal(Object.getOwnPropertyDescriptor(tree.get('one'), 'two').enumerable, false);
});

it('should be possible to shallow merge two objects.', function(done) {
const tree = new Baobab({o: {hello: 'world'}, string: 'test'});

Expand Down

0 comments on commit 5d873ae

Please sign in to comment.