From 491311d34094e8e745d2ba4ee40c3b6e5aaa8528 Mon Sep 17 00:00:00 2001 From: Damien Lebrun Date: Fri, 23 Dec 2016 01:19:39 +0000 Subject: [PATCH] Test for #108 --- test/spec/lib/database/index.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/spec/lib/database/index.js b/test/spec/lib/database/index.js index dc40459..f41a42f 100644 --- a/test/spec/lib/database/index.js +++ b/test/spec/lib/database/index.js @@ -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() {