summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream-transform-constructor-set-methods.js
blob: 14c173b4ccfec5711b5763700af40abe4c4ce878 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const common = require('../common');

const { strictEqual } = require('assert');
const { Transform } = require('stream');

const _transform = common.mustCall((chunk, _, next) => {
  next();
});

const _final = common.mustCall((next) => {
  next();
});

const _flush = common.mustCall((next) => {
  next();
});

const t = new Transform({
  transform: _transform,
  flush: _flush,
  final: _final
});

strictEqual(t._transform, _transform);
strictEqual(t._flush, _flush);
strictEqual(t._final, _final);

t.end(Buffer.from('blerg'));
t.resume();

const t2 = new Transform({});

common.expectsError(() => {
  t2.end(Buffer.from('blerg'));
}, {
  type: Error,
  code: 'ERR_METHOD_NOT_IMPLEMENTED',
  message: 'The _transform method is not implemented'
});