summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-write-stream-throw-type-error.js
blob: 996b22119cda5e02010db9e118f7438e9a24d193 (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
32
33
34
35
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');

const example = path.join(common.tmpDir, 'dummy');

common.refreshTmpDir();

assert.doesNotThrow(function() {
  fs.createWriteStream(example, undefined);
});
assert.doesNotThrow(function() {
  fs.createWriteStream(example, null);
});
assert.doesNotThrow(function() {
  fs.createWriteStream(example, 'utf8');
});
assert.doesNotThrow(function() {
  fs.createWriteStream(example, {encoding: 'utf8'});
});

assert.throws(function() {
  fs.createWriteStream(example, 123);
}, /"options" must be a string or an object/);
assert.throws(function() {
  fs.createWriteStream(example, 0);
}, /"options" must be a string or an object/);
assert.throws(function() {
  fs.createWriteStream(example, true);
}, /"options" must be a string or an object/);
assert.throws(function() {
  fs.createWriteStream(example, false);
}, /"options" must be a string or an object/);