don't be invalid!

This commit is contained in:
Mark Nadal 2016-01-24 08:13:21 -08:00
parent 85ee6fd07c
commit b95b25fd94
2 changed files with 17 additions and 2 deletions

4
gun.js
View File

@ -349,7 +349,7 @@
if(!(meta = (node||{})[Gun._.meta]) || !(meta = meta[Gun._.state]) || !Gun.num.is(meta[field])){
return ctx.err = {err: Gun.log("No state on '" + field + "'!") }
}
}) || ctx.err){ return ctx.err = ctx.err || {err: Gun.log("Invalid graph!")}, ctx }
}) || ctx.err){ return ctx.err = ctx.err || {err: Gun.log("Invalid graph!", prime)}, ctx }
function emit(at){
Gun.on('operating').emit(gun, at);
}
@ -714,7 +714,7 @@
at.soul = opt.key.soul;
gun.__.by(opt.key.soul).node = Gun.union.ify(gun, opt.key.soul); // TODO: Check performance?
gun.__.by(opt.key.soul).node._['key'] = 'pseudo';
at.change = Gun.is.node.soul.ify(at.change || gun.__.by(at.soul).node, at.soul, true);
at.change = Gun.is.node.soul.ify(Gun.obj.copy(at.change || gun.__.by(at.soul).node), at.soul, true); // TODO: Check performance?
return;
}
var node = at.change || gun.__.graph[at.soul];

View File

@ -3486,6 +3486,21 @@ describe('Gun', function(){
done();
})
});
it("no invalid graph", function(done){
var gun = Gun({wire:{
put: function(graph){
expect(Gun.is.graph(graph)).to.be.ok();
if(done.c){ return } if(done.on){ done(); done.c = 1 }
}
}}).get('example/todo/data/graph');
gun.on(function renderToDo(val){
done.on = true;
});
setTimeout(function(){
gun.path(Gun.text.random()).put('hoorah');
},100)
});
});
describe('Streams', function(){