Skip to content

Commit f1ef692

Browse files
Trottaddaleax
authored andcommitted
test: refactor test-fs-options-immutable
* 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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent bb198dc commit f1ef692

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/parallel/test-fs-options-immutable.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
const common = require('../common');
23

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

10-
const common = require('../common');
1111
const assert = require('assert');
12-
const path = require('path');
1312
const fs = require('fs');
13+
const path = require('path');
14+
1415
const errHandler = (e) => assert.ifError(e);
1516
const options = Object.freeze({});
1617
common.refreshTmpDir();
@@ -61,13 +62,15 @@ if (common.canCreateSymLink()) {
6162
{
6263
let watch;
6364
assert.doesNotThrow(() => {
64-
watch = fs.watch(__filename, options, common.noop);
65+
watch = fs.watch(__filename, options, common.mustNotCall());
6566
});
6667
watch.close();
6768
}
6869

6970
{
70-
assert.doesNotThrow(() => fs.watchFile(__filename, options, common.noop));
71+
assert.doesNotThrow(
72+
() => fs.watchFile(__filename, options, common.mustNotCall())
73+
);
7174
fs.unwatchFile(__filename);
7275
}
7376

@@ -89,8 +92,8 @@ if (common.canCreateSymLink()) {
8992
{
9093
const fileName = path.resolve(common.tmpDir, 'streams');
9194
assert.doesNotThrow(() => {
92-
fs.WriteStream(fileName, options).once('open', () => {
95+
fs.WriteStream(fileName, options).once('open', common.mustCall(() => {
9396
assert.doesNotThrow(() => fs.ReadStream(fileName, options));
94-
});
97+
}));
9598
});
9699
}

0 commit comments

Comments
 (0)