source: node_modules/simple-concat/test/basic.js@ 81bc7da

finki-main main
Last change on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 825 bytes
Line 
1var concat = require('../')
2var stream = require('stream')
3var test = require('tape')
4
5test('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
24test('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.