Skip to content

Commit

Permalink
Test for #108
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoboff committed Dec 23, 2016
1 parent 52a6e97 commit 4818349
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/spec/lib/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,30 @@ describe('database', function() {
expect(db.write('/a', 2).allowed).to.be.false();
});

it.only('should fix #108', function() {
const rules = {
rules: {
$key: {
'.write': 'newData.hasChild("bar")'
}
}
};
const data = {
foo: {
bar: true,
baz: true
}
};
const db = database.create(rules, data).with({debug: true});
const result = db.write('/foo/baz', null);

console.log('writing null to /foo/baz');
console.log('old root:', result.root.val());
console.log('new root:', result.newRoot.val());

expect(result.allowed, result.info).to.be.true();
});

});

describe('#update', function() {
Expand Down
13 changes: 13 additions & 0 deletions test/spec/lib/database/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ describe('store', function() {
expect(newRoot).not.to.have.property('b');
});

it.only('should fix #108', function() {
data = store.create({
a: {
b: true,
c: true
}
});

const newRoot = data.$set('a/b', null);

expect(newRoot.$value()).to.deep.equal({a: {c: true}});
});

});

describe('#$merge', function() {
Expand Down

0 comments on commit 4818349

Please sign in to comment.