summaryrefslogtreecommitdiff
path: root/test/parallel/test-zlib-not-string-or-buffer.js
blob: a0954a0e1eaef7b1e35312535dc28d32ebef3ce8 (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
'use strict';

// Check the error condition testing for passing something other than a string
// or buffer.

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

[
  undefined,
  null,
  true,
  false,
  0,
  1,
  [1, 2, 3],
  { foo: 'bar' },
].forEach((input) => {
  assert.throws(
    () => zlib.deflateSync(input),
    {
      code: 'ERR_INVALID_ARG_TYPE',
      name: 'TypeError',
      message: 'The "buffer" argument must be of type string or an instance ' +
               'of Buffer, TypedArray, DataView, or ArrayBuffer.' +
               common.invalidArgTypeHelper(input)
    }
  );
});