summaryrefslogtreecommitdiff
path: root/test/parallel/test-zlib-destroy.js
blob: 775b7020b4ecfda463813213b93e40ac91516333 (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
'use strict';

const common = require('../common');

const assert = require('assert');
const zlib = require('zlib');

// Verify that the zlib transform does clean up
// the handle when calling destroy.

{
  const ts = zlib.createGzip();
  ts.destroy();
  assert.strictEqual(ts._handle, null);

  ts.on('close', common.mustCall(() => {
    ts.close(common.mustCall());
  }));
}

{
  // Ensure 'error' is only emitted once.
  const decompress = zlib.createGunzip(15);

  decompress.on('error', common.mustCall((err) => {
    decompress.close();
  }));

  decompress.write('something invalid');
  decompress.destroy(new Error('asd'));
}