Skip to content

Commit

Permalink
test: refactor test-fs-watchfile
Browse files Browse the repository at this point in the history
* use `common.mustNotCall()` to confirm callback is not called
* reorder modules to conform with test-writing guide
* match full error message in `assert.throws()`

PR-URL: #13721
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and addaleax committed Jul 11, 2017
1 parent 7006873 commit 0e5beeb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/parallel/test-fs-watchfile.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

const common = require('../common');

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const assert = require('assert');

// Basic usage tests.
assert.throws(function() {
fs.watchFile('./some-file');
}, /"watchFile\(\)" requires a listener function/);
}, /^Error: "watchFile\(\)" requires a listener function$/);

assert.throws(function() {
fs.watchFile('./another-file', {}, 'bad listener');
}, /"watchFile\(\)" requires a listener function/);
}, /^Error: "watchFile\(\)" requires a listener function$/);

assert.throws(function() {
fs.watchFile(new Object(), common.noop);
fs.watchFile(new Object(), common.mustNotCall());
}, /Path must be a string/);

const enoentFile = path.join(common.tmpDir, 'non-existent-file');
Expand Down

0 comments on commit 0e5beeb

Please sign in to comment.