no false positive null emit FIXED with test

This commit is contained in:
Mark Nadal 2015-06-17 14:05:40 -07:00
parent a01ca23304
commit 2195b0e9d0
2 changed files with 22 additions and 1 deletions

3
gun.js
View File

@ -297,7 +297,8 @@
if(err){ return cb.call(gun, err, data) }
if(!data){
if(ctx.soul){ return }
return cb.call(gun, null, null), gun._.at('null').emit()
cb.call(gun, null, null);
return gun._.at('null').emit();
}
if(ctx.soul = Gun.is.soul.on(data)){
gun._.at('soul').emit({soul: ctx.soul});

View File

@ -1321,5 +1321,25 @@ describe('Gun', function(){
done();
}, 'qwertyasdfzxcv');
});
it('no false positive null emit', function(done){
var gun = Gun({hooks: {get: function(key, cb){
cb(null, {_: {'#': soul, '>': {'a': 0}},
'a': 'b'
});
cb(null, {_: {'#': soul }});
cb(); // false trigger!
}}}), soul = Gun.text.random();
gun.get('me').not(function(){
done.fail = true;
}).val(function(val){
setTimeout(function(){
expect(val.a).to.be('b');
expect(done.fail).to.not.be.ok();
done();
},5);
});
});
});
});