|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
525 bytes
|
| Line | |
|---|
| 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 received once")
|
|---|
| 31 | })
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.