Version 1
[yaffs-website] / node_modules / duplexer / test / index.js
1 var through = require("through")
2 var test    = require("tape")
3
4 var duplex  = require("../index")
5
6 var readable = through()
7 var writable = through(write)
8 var written = 0
9 var data = 0
10
11 var stream = duplex(writable, readable)
12
13 function write() {
14     written++
15 }
16
17 stream.on("data", ondata)
18
19 function ondata() {
20     data++
21 }
22
23 test("emit and write", function(t) {
24     t.plan(2)
25
26     stream.write()
27     readable.emit("data")
28
29     t.equal(written, 1, "should have written once")
30     t.equal(data, 1, "should have recived once")
31 })