0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-watch-stop-async.js
Rich Trott f462ad1f35 test: refactor test-fs-watch-stop-async
* use common.mustNotCall() to confirm callback is not invoked
* blank line after common module per test writing guide

PR-URL: https://github.com/nodejs/node/pull/13661
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-06-15 14:07:25 -07:00

21 lines
483 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const watch = fs.watchFile(__filename, common.mustNotCall());
let triggered;
const listener = common.mustCall(() => {
triggered = true;
});
triggered = false;
watch.once('stop', listener); // Should trigger.
watch.stop();
assert.strictEqual(triggered, false);
setImmediate(() => {
assert.strictEqual(triggered, true);
watch.removeListener('stop', listener);
});