|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | +const assert = require('assert'); |
| 4 | +const fs = require('fs'); |
| 5 | +const path = require('path'); |
| 6 | + |
| 7 | +const example = path.join(common.tmpDir, 'dummy'); |
| 8 | + |
| 9 | +assert.doesNotThrow(function() { |
| 10 | + fs.createWriteStream(example, undefined); |
| 11 | +}); |
| 12 | +assert.doesNotThrow(function() { |
| 13 | + fs.createWriteStream(example, 'utf8'); |
| 14 | +}); |
| 15 | +assert.doesNotThrow(function() { |
| 16 | + fs.createWriteStream(example, {encoding: 'utf8'}); |
| 17 | +}); |
| 18 | + |
| 19 | +assert.throws(function() { |
| 20 | + fs.createWriteStream(example, null); |
| 21 | +}, /options must be a string or an object/); |
| 22 | +assert.throws(function() { |
| 23 | + fs.createWriteStream(example, 123); |
| 24 | +}, /options must be a string or an object/); |
| 25 | +assert.throws(function() { |
| 26 | + fs.createWriteStream(example, 0); |
| 27 | +}, /options must be a string or an object/); |
| 28 | +assert.throws(function() { |
| 29 | + fs.createWriteStream(example, true); |
| 30 | +}, /options must be a string or an object/); |
| 31 | +assert.throws(function() { |
| 32 | + fs.createWriteStream(example, false); |
| 33 | +}, /options must be a string or an object/); |
0 commit comments