summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-watchfile.js
blob: eacb2f9d821982c24d3ac865a5f631ec28ed2b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';

const fs = require('fs');
const path = require('path');
const assert = require('assert');
const common = require('../common');
const fixtures = path.join(__dirname, '..', 'fixtures');

// Basic usage tests.
assert.throws(function() {
  fs.watchFile('./some-file');
}, /watchFile requires a listener function/);

assert.throws(function() {
  fs.watchFile('./another-file', {}, 'bad listener');
}, /watchFile requires a listener function/);

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

// Test ENOENT. Should fire once.
const enoentFile = path.join(fixtures, 'empty', 'non-existent-file');
fs.watchFile(enoentFile, common.mustCall(function(curr, prev) {
  fs.unwatchFile(enoentFile);
}));