summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-read-stream-throw-type-error.js
blob: 81f924d355b91c186b1208fae4423f51335deb34 (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
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');

const example = path.join(common.fixturesDir, 'x.txt');

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

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