Skip to content
Prev Previous commit
Fix comments style and variable name
  • Loading branch information
vsemozhetbyt authored Jul 19, 2016
commit 6d7e25fbd43056283ca54449dd93b71bed3fffad
16 changes: 8 additions & 8 deletions test/parallel/test-stream-preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ const rl = require('readline');

const BOM = '\uFEFF';

// get the data by a non-stream way to compare with the streamed data
// Get the data using a non-stream way to compare with the streamed data.
const modelData = fs.readFileSync(
path.join(common.fixturesDir, 'file-to-read-without-bom.txt'), 'utf8'
);
const modelDataFirstCharacter = modelData[0];

// detect the number of forthcoming 'line' events for mustCall() 'expected' arg
const linesNumber = modelData.match(/\n/g).length;
// Detect the number of forthcoming 'line' events for mustCall() 'expected' arg.
const lineCount = modelData.match(/\n/g).length;

// ensure both without-bom and with-bom test files are textwise equal
// Ensure both without-bom and with-bom test files are textwise equal.
assert.strictEqual(
fs.readFileSync(
path.join(common.fixturesDir, 'file-to-read-with-bom.txt'), 'utf8'
),
`${BOM}${modelData}`
);

// an unjustified BOM stripping with a non-BOM character unshifted to a stream
// An unjustified BOM stripping with a non-BOM character unshifted to a stream.
const inputWithoutBOM = fs.createReadStream(
path.join(common.fixturesDir, 'file-to-read-without-bom.txt'), 'utf8'
);
Expand All @@ -42,12 +42,12 @@ inputWithoutBOM.once('readable', common.mustCall(() => {
input: inputWithoutBOM,
}).on('line', common.mustCall((line) => {
streamedData += `${line}\n`;
}, linesNumber)).on('close', common.mustCall(() => {
}, lineCount)).on('close', common.mustCall(() => {
assert.strictEqual(streamedData, modelData);
}));
}));

// a justified BOM stripping
// A justified BOM stripping.
const inputWithBOM = fs.createReadStream(
path.join(common.fixturesDir, 'file-to-read-with-bom.txt'), 'utf8'
);
Expand All @@ -61,7 +61,7 @@ inputWithBOM.once('readable', common.mustCall(() => {
input: inputWithBOM,
}).on('line', common.mustCall((line) => {
streamedData += `${line}\n`;
}, linesNumber)).on('close', common.mustCall(() => {
}, lineCount)).on('close', common.mustCall(() => {
assert.strictEqual(streamedData, modelData);
}));
}));