fixed opt/soul with TEST

This commit is contained in:
Mark Nadal 2015-06-17 12:52:30 -07:00
parent d8d4cfd3f2
commit a01ca23304
2 changed files with 12 additions and 2 deletions

4
gun.js
View File

@ -326,13 +326,13 @@
opt = Gun.text.is(opt)? {soul: opt} : opt || {};
opt.soul = opt.soul || opt[Gun._.soul];
gun._.at('soul').event(index);
if(opt.soul){ // TODO! BUG! WRITE A TEST FOR THIS!
if(opt.soul){ // force inject // TODO! BUG! WRITE A TEST FOR THIS!
if(!gun.__.graph[opt.soul]){
gun.__.graph[opt.soul] = {_: {'#': opt.soul, '>': {}}}; // TODO! SYMBOLS SHOULD NOT BE HARD CODED!
}
gun.__.keys[key] = gun.__.graph[opt.soul];
gun._.at('soul').emit({soul: opt.soul});
} else {
} else { // will be injected via a put
(gun.__.flag.start[key] = gun._.at('node')).once(function($){
gun.__.keys[key] = gun.__.graph[$.soul];
delete gun.__.flag.start[key];

View File

@ -1311,5 +1311,15 @@ describe('Gun', function(){
}
})
});
it('key soul', function(done){
var gun = Gun();
gun.key('me', function(err, ok){
expect(err).to.not.be.ok();
expect(gun.__.keys['me']).to.be.ok();
expect(Gun.is.soul.on(gun.__.keys['me'])).to.be.ok();
done();
}, 'qwertyasdfzxcv');
});
});
});