Permalink
Browse files

tests for procPromise methods

  • Loading branch information...
1 parent 033c41a commit 8ddeba8d22ec532004d375319149b881d913a8e2 @polotek committed Mar 4, 2012
Showing with 56 additions and 1 deletion.
  1. +1 −1 tests/test-error.js
  2. +55 −0 tests/test-promises.js
View
@@ -43,6 +43,6 @@ exec('node does-not-exist', function(err, stdout, stderr) {
})
process.nextTick(function() {
- proc.kill();
+ proc.kill()
})
})
@@ -0,0 +1,55 @@
+var assert = require('assert')
+ , fs = require('fs')
+ , multiTimer = require(__dirname + '/timers').multiTimer
+ , exec = require('child_process').exec
+ , $p = require(__dirname + '/..')
+ , nop = function() {}
+
+
+var t = multiTimer(5)
+$p('echo one')
+ .and('echo two')
+ .and('echo three')
+ .data(function(err, stdout, stderr) {
+ t.stop()
+ assert.equal('three', stdout.trim())
+ })
+
+$p('echo one')
+ .and('fail two').on('error', nop)
+ .or('echo three')
+ .data(function(err, stdout, stderr) {
+ t.stop()
+ assert.equal('three', stdout.trim())
+ })
+
+$p('echo one')
+ .then('echo two')
+ .then('echo three')
+ .data(function(err, stdout, stderr) {
+ t.stop()
+ assert.equal('three', stdout.trim())
+ })
+
+var outProc
+$p('echo one')
+ .and('echo two')
+ .and('echo three')
+ .on('start', function() {
+ outProc = this
+ })
+ .out()
+
+process.stdout.on('pipe', function(source) {
+ t.stop()
+ assert.strictEqual(source, outProc.stdout)
+})
+
+$p('echo one')
+ .and('echo two')
+ .and('echo three')
+ .pipe('cat')
+ .data(function(err, stdout, stderr) {
+ t.stop()
+ assert.equal('three', stdout.trim())
+ })

0 comments on commit 8ddeba8

Please sign in to comment.