Skip to content

Commit

Permalink
Coverage of send method propagation.
Browse files Browse the repository at this point in the history
  • Loading branch information
flatheadmill committed Jan 18, 2016
1 parent 6c510df commit c5fb6b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
12 changes: 12 additions & 0 deletions t/arguable/fixtures/send.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
___ usage ___ en_US ___
usage: send
Send a message to the parent.
___ . ___
*/

require('../../..')(module, function (options, callback) {
options.send({ key: 'value' })
callback()
})
17 changes: 12 additions & 5 deletions t/arguable/index.t.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env node

require('proof')(4, require('cadence')(function (async, assert) {
require('proof')(6, require('cadence')(function (async, assert) {
var echo1 = require('./fixtures/echo-1')
var echo2 = require('./fixtures/echo-2')
var send = require('./fixtures/send')
var stream = require('stream')
var events = require('events')
var stdout
var chunks
async(function () {
Expand All @@ -12,15 +14,20 @@ require('proof')(4, require('cadence')(function (async, assert) {
stdout.on('data', function (data) { chunks.push(data.toString()) })
echo1({}, [ 'a', 'b' ], { stdout: stdout }, async())
}, function () {
assert(1, 'called back')
assert(chunks.join(''), 'a b\n', 'executable')
assert(true, 'echo 1 called back')
assert(chunks.join(''), 'a b\n', 'echo 1 executed')
}, function () {
stdout = new stream.PassThrough
chunks = []
stdout.on('data', function (data) { chunks.push(data.toString()) })
echo2({}, [ 'a', 'b' ], { stdout: stdout }, async())
}, function () {
assert(1, 'called back')
assert(chunks.join(''), 'a b\n', 'executable')
var ee = new events.EventEmitter
ee.send = function (message) { assert(message, { key: 'value' }, 'send') }
assert(true, 'echo 2 called back')
assert(chunks.join(''), 'a b\n', 'echo 2 executed')
send({}, [], { events: ee }, async())
}, function () {
assert(true, 'send called back')
})
}))

0 comments on commit c5fb6b7

Please sign in to comment.