Skip to content

Commit

Permalink
Merge pull request #290 from geek/issue288
Browse files Browse the repository at this point in the history
Pass seneca instance on add callback
  • Loading branch information
geek committed Jan 6, 2016
2 parents c401d33 + 096dca5 commit 756725f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions seneca.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,8 @@ function make_seneca (initial_options) {
},

fn: function (cb) {
cb.seneca = delegate

if (root.closed && !callargs.closing$) {
return cb(internals.error('instance-closed', {args: Common.clean(callargs)}))
}
Expand Down
12 changes: 12 additions & 0 deletions test/seneca.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ describe('seneca', function () {
})
})

it('passes seneca instance on callback function property', function (done) {
var si = seneca({ log: 'silent' }).error(done)
si.add({ cmd: 'foo' }, function (args, reply) {
reply(null, { did: reply.seneca.did })
})
si.act({ cmd: 'foo' }, function (err, result) {
expect(err).to.not.exist()
expect(result.did).to.equal(this.did)
done()
})
})

it('action-act-invalid-args', function (done) {
var si = seneca(testopts).error(done)
si.options({debug: {fragile: true}})
Expand Down

0 comments on commit 756725f

Please sign in to comment.