var tape = require('tape')
var pull = require('pull-stream')
var through = require('../')

tape('emit error', function (t) {
  var err = new Error('expected error')
  pull(
    pull.values([1,2,3]),
    through(function (data) {
      this.emit('error', err)
    }),
    pull.drain(null, function (_err) {
      t.equal(_err, err)
      t.end()
    })
  )
})

tape('through', function (t) {
  pull(
    pull.values([1,2,3]),
    through(function (data) {
      this.queue(data * 10)
    }),
    pull.collect(function (err, ary) {
      if(err) throw err
      t.deepEqual(ary, [10, 20, 30])
      t.end()
    })
  )
})

tape('through + end', function (t) {
  pull(
    pull.values([1,2,3]),
    through(function (data) {
      this.queue(data * 10)
    }),
    pull.collect(function (err, ary) {
      if(err) throw err
      t.deepEqual(ary, [10, 20, 30])
      t.end()
    })
  )
})

@@ -738,32 +738,97 @@
 (data * 10)%0A
+    %7D, function () %7B%0A      this.queue(40)%0A      this.queue(null)%0A
     %7D),%0A
     pull.col
@@ -807,32 +807,32 @@
 e(null)%0A    %7D),%0A
-
     pull.collect
@@ -904,32 +904,36 @@
 ary, %5B10, 20, 30
+, 40
 %5D)%0A      t.end()
@@ -924,31 +924,33 @@
 %5D)%0A      t.end()%0A    %7D)%0A  )%0A
-
 %7D)%0A
+%0A%0A

test this.queue within ender