finki-main
main
|
Last change
on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
825 bytes
|
| Rev | Line | |
|---|
| [81bc7da] | 1 | var concat = require('../')
|
|---|
| 2 | var stream = require('stream')
|
|---|
| 3 | var test = require('tape')
|
|---|
| 4 |
|
|---|
| 5 | test('basic', function (t) {
|
|---|
| 6 | t.plan(2)
|
|---|
| 7 | var s = new stream.PassThrough()
|
|---|
| 8 | concat(s, function (err, buf) {
|
|---|
| 9 | t.error(err)
|
|---|
| 10 | t.deepEqual(buf, Buffer.from('abc123456789'))
|
|---|
| 11 | })
|
|---|
| 12 | s.write('abc')
|
|---|
| 13 | setTimeout(function () {
|
|---|
| 14 | s.write('123')
|
|---|
| 15 | }, 10)
|
|---|
| 16 | setTimeout(function () {
|
|---|
| 17 | s.write('456')
|
|---|
| 18 | }, 20)
|
|---|
| 19 | setTimeout(function () {
|
|---|
| 20 | s.end('789')
|
|---|
| 21 | }, 30)
|
|---|
| 22 | })
|
|---|
| 23 |
|
|---|
| 24 | test('error', function (t) {
|
|---|
| 25 | t.plan(2)
|
|---|
| 26 | var s = new stream.PassThrough()
|
|---|
| 27 | concat(s, function (err, buf) {
|
|---|
| 28 | t.ok(err, 'got expected error')
|
|---|
| 29 | t.ok(!buf)
|
|---|
| 30 | })
|
|---|
| 31 | s.write('abc')
|
|---|
| 32 | setTimeout(function () {
|
|---|
| 33 | s.write('123')
|
|---|
| 34 | }, 10)
|
|---|
| 35 | setTimeout(function () {
|
|---|
| 36 | s.write('456')
|
|---|
| 37 | }, 20)
|
|---|
| 38 | setTimeout(function () {
|
|---|
| 39 | s.emit('error', new Error('error'))
|
|---|
| 40 | }, 30)
|
|---|
| 41 | })
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.