Skip to content

Commit

Permalink
test: refactor test-fs-options-immutable
Browse files Browse the repository at this point in the history
* Reorder require() statements per test-writing guide
* Use common.mustNotCall() to check that callback is not invoked
* Use common.mustCall() to check that callback is invoked

PR-URL: #13977
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
  • Loading branch information
Trott authored and addaleax committed Jul 18, 2017
1 parent bb198dc commit f1ef692
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/parallel/test-fs-options-immutable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const common = require('../common');

/*
* These tests make sure that the `options` object passed to these functions are
Expand All @@ -7,10 +8,10 @@
* Refer: https://github.com/nodejs/node/issues/7655
*/

const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const path = require('path');

const errHandler = (e) => assert.ifError(e);
const options = Object.freeze({});
common.refreshTmpDir();
Expand Down Expand Up @@ -61,13 +62,15 @@ if (common.canCreateSymLink()) {
{
let watch;
assert.doesNotThrow(() => {
watch = fs.watch(__filename, options, common.noop);
watch = fs.watch(__filename, options, common.mustNotCall());
});
watch.close();
}

{
assert.doesNotThrow(() => fs.watchFile(__filename, options, common.noop));
assert.doesNotThrow(
() => fs.watchFile(__filename, options, common.mustNotCall())
);
fs.unwatchFile(__filename);
}

Expand All @@ -89,8 +92,8 @@ if (common.canCreateSymLink()) {
{
const fileName = path.resolve(common.tmpDir, 'streams');
assert.doesNotThrow(() => {
fs.WriteStream(fileName, options).once('open', () => {
fs.WriteStream(fileName, options).once('open', common.mustCall(() => {
assert.doesNotThrow(() => fs.ReadStream(fileName, options));
});
}));
});
}

0 comments on commit f1ef692

Please sign in to comment.