2016-08-30 19:38:32 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Check the error condition testing for passing something other than a string
|
|
|
|
// or buffer.
|
|
|
|
|
2017-09-25 16:48:57 -07:00
|
|
|
const common = require('../common');
|
2016-08-30 19:38:32 -07:00
|
|
|
const zlib = require('zlib');
|
|
|
|
|
2018-03-19 13:33:46 +01:00
|
|
|
[
|
|
|
|
undefined,
|
|
|
|
null,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
[1, 2, 3],
|
|
|
|
{ foo: 'bar' }
|
|
|
|
].forEach((input) => {
|
2017-09-25 16:48:57 -07:00
|
|
|
common.expectsError(
|
2018-03-19 13:33:46 +01:00
|
|
|
() => zlib.deflateSync(input),
|
2017-09-25 16:48:57 -07:00
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
type: TypeError,
|
|
|
|
message: 'The "buffer" argument must be one of type string, Buffer, ' +
|
2018-03-19 13:33:46 +01:00
|
|
|
'TypedArray, DataView, or ArrayBuffer. ' +
|
|
|
|
`Received type ${typeof input}`
|
2017-09-25 16:48:57 -07:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|