1'use strict'; 2require('../common'); 3const assert = require('assert'); 4const zlib = require('zlib'); 5 6zlib.createGzip({ flush: zlib.constants.Z_SYNC_FLUSH }); 7 8assert.throws( 9 () => zlib.createGzip({ flush: 'foobar' }), 10 { 11 code: 'ERR_INVALID_ARG_TYPE', 12 name: 'TypeError', 13 message: 'The "options.flush" property must be of type number. ' + 14 "Received type string ('foobar')" 15 } 16); 17 18assert.throws( 19 () => zlib.createGzip({ flush: 10000 }), 20 { 21 code: 'ERR_OUT_OF_RANGE', 22 name: 'RangeError', 23 message: 'The value of "options.flush" is out of range. It must ' + 24 'be >= 0 and <= 5. Received 10000' 25 } 26); 27 28zlib.createGzip({ finishFlush: zlib.constants.Z_SYNC_FLUSH }); 29 30assert.throws( 31 () => zlib.createGzip({ finishFlush: 'foobar' }), 32 { 33 code: 'ERR_INVALID_ARG_TYPE', 34 name: 'TypeError', 35 message: 'The "options.finishFlush" property must be of type number. ' + 36 "Received type string ('foobar')" 37 } 38); 39 40assert.throws( 41 () => zlib.createGzip({ finishFlush: 10000 }), 42 { 43 code: 'ERR_OUT_OF_RANGE', 44 name: 'RangeError', 45 message: 'The value of "options.finishFlush" is out of range. It must ' + 46 'be >= 0 and <= 5. Received 10000' 47 } 48); 49