Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve test-fs-read-stream.js #9629

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions test/parallel/test-fs-read-stream.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

var path = require('path');
var fs = require('fs');
var fn = path.join(common.fixturesDir, 'elipses.txt');
var rangeFile = path.join(common.fixturesDir, 'x.txt');
const path = require('path');
const fs = require('fs');
const fn = path.join(common.fixturesDir, 'elipses.txt');
const rangeFile = path.join(common.fixturesDir, 'x.txt');

var callbacks = { open: 0, end: 0, close: 0 };

Expand All @@ -20,7 +20,7 @@ assert.strictEqual(file.bytesRead, 0);
file.on('open', function(fd) {
file.length = 0;
callbacks.open++;
assert.equal('number', typeof fd);
assert.strictEqual('number', typeof fd);
assert.strictEqual(file.bytesRead, 0);
assert.ok(file.readable);

Expand Down Expand Up @@ -67,12 +67,12 @@ file.on('close', function() {
var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
file3.length = 0;
file3.on('data', function(data) {
assert.equal('string', typeof data);
assert.strictEqual('string', typeof data);
file3.length += data.length;

for (var i = 0; i < data.length; i++) {
// http://www.fileformat.info/info/unicode/char/2026/index.htm
assert.equal('\u2026', data[i]);
assert.strictEqual('\u2026', data[i]);
}
});

Expand All @@ -81,11 +81,11 @@ file3.on('close', function() {
});

process.on('exit', function() {
assert.equal(1, callbacks.open);
assert.equal(1, callbacks.end);
assert.equal(2, callbacks.close);
assert.equal(30000, file.length);
assert.equal(10000, file3.length);
assert.strictEqual(1, callbacks.open);
assert.strictEqual(1, callbacks.end);
assert.strictEqual(2, callbacks.close);
assert.strictEqual(30000, file.length);
assert.strictEqual(10000, file3.length);
console.error('ok');
});

Expand All @@ -95,7 +95,7 @@ file4.on('data', function(data) {
contentRead += data.toString('utf-8');
});
file4.on('end', function(data) {
assert.equal(contentRead, 'yz');
assert.strictEqual(contentRead, 'yz');
});

var file5 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1});
Expand All @@ -104,7 +104,7 @@ file5.on('data', function(data) {
file5.data += data.toString('utf-8');
});
file5.on('end', function() {
assert.equal(file5.data, 'yz\n');
assert.strictEqual(file5.data, 'yz\n');
});

// https://github.com/joyent/node/issues/2320
Expand All @@ -114,7 +114,7 @@ file6.on('data', function(data) {
file6.data += data.toString('utf-8');
});
file6.on('end', function() {
assert.equal(file6.data, 'yz\n');
assert.strictEqual(file6.data, 'yz\n');
});

assert.throws(function() {
Expand All @@ -129,7 +129,7 @@ stream.on('data', function(chunk) {
});

stream.on('end', function() {
assert.equal('x', stream.data);
assert.strictEqual('x', stream.data);
});

// pause and then resume immediately.
Expand All @@ -155,7 +155,7 @@ function file7Next() {
file7.data += data;
});
file7.on('end', function(err) {
assert.equal(file7.data, 'xyz\n');
assert.strictEqual(file7.data, 'xyz\n');
});
}

Expand Down