HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/watch/test/test_monitor.js
var watch = require('../main')
  , assert = require('assert')
  , path = require('path')
  , fs = require('fs')
  , target = path.join(__dirname, "d/t")
  ;

function clearFile() {
  fs.writeFileSync(target, '')
}

clearFile()

// test if changed event is fired correctly
watch.createMonitor(__dirname, { interval: 150 },
  function (monitor) {
    monitor.once('changed', function (f) {
      assert.equal(f, target);
      clearFile();
      process.exit(0)
    })

    fs.writeFile(target, 'Test Write\n', function (err) {
      if (err) throw err;

      setTimeout(function () {
        // should have got the other assert done by now
        assert.ok(false);
      }, 300);
    })
});