mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
f462ad1f35
* 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>
21 lines
483 B
JavaScript
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);
|
|
});
|