node/test/parallel/test-fs-non-number-arguments-throw.js
Ruben Bridgewater 50dd555910
doc,lib,test: capitalize comment sentences
This activates the eslint capitalize comment rule for comments
above 50 characters.

PR-URL: https://github.com/nodejs/node/pull/24996
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-17 17:14:35 +01:00

49 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const tempFile = path.join(tmpdir.path, 'fs-non-number-arguments-throw');
tmpdir.refresh();
fs.writeFileSync(tempFile, 'abc\ndef');
// A sanity check when using numbers instead of strings
const sanity = 'def';
const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });
common.expectsError(
() => {
fs.createReadStream(tempFile, { start: '4', end: 6 });
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
common.expectsError(
() => {
fs.createReadStream(tempFile, { start: 4, end: '6' });
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
common.expectsError(
() => {
fs.createWriteStream(tempFile, { start: '4' });
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
saneEmitter.on('data', common.mustCall(function(data) {
assert.strictEqual(
sanity, data.toString('utf8'),
`read ${data.toString('utf8')} instead of ${sanity}`);
}));