mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
be7fd2d517
PR-URL: https://github.com/nodejs/node/pull/33134 Fixes: https://github.com/nodejs/node/issues/33096 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
36 lines
911 B
JavaScript
36 lines
911 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const fs = require('fs');
|
|
const assert = require('assert');
|
|
|
|
const uncalledListener = common.mustNotCall();
|
|
const uncalledListener2 = common.mustNotCall();
|
|
const watcher = fs.watchFile(__filename, uncalledListener);
|
|
|
|
watcher.unref();
|
|
watcher.unref();
|
|
watcher.ref();
|
|
watcher.unref();
|
|
watcher.ref();
|
|
watcher.ref();
|
|
watcher.unref();
|
|
|
|
fs.unwatchFile(__filename, uncalledListener);
|
|
|
|
// Watch the file with two different listeners.
|
|
fs.watchFile(__filename, uncalledListener);
|
|
const watcher2 = fs.watchFile(__filename, uncalledListener2);
|
|
|
|
setTimeout(
|
|
common.mustCall(() => {
|
|
fs.unwatchFile(__filename, common.mustNotCall());
|
|
assert.strictEqual(watcher2.listenerCount('change'), 2);
|
|
fs.unwatchFile(__filename, uncalledListener);
|
|
assert.strictEqual(watcher2.listenerCount('change'), 1);
|
|
watcher2.unref();
|
|
}),
|
|
common.platformTimeout(100)
|
|
);
|