From: Cheng Zhao Date: Thu, 9 Jan 2014 12:29:54 +0000 (+0800) Subject: Add spec for pathwatcher module. X-Git-Tag: v0.8.4~11^2~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a12754f9804cc443ba3528ae2396779dc18391a2;p=electron.git Add spec for pathwatcher module. --- diff --git a/package.json b/package.json index bf7710f6..7658c557 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,11 @@ "coffee-script": "~1.6.3", "coffeelint": "~0.6.1", "mocha": "~1.13.0", + "pathwatcher": "0.13.0", "walkdir": "~0.0.7", "runas": "0.3.0", - "formidable": "~1.0.14" + "formidable": "~1.0.14", + "temp": "~0.6.0" }, "private": true, diff --git a/spec/modules-spec.coffee b/spec/modules-spec.coffee index 0eab1e62..52936ef4 100644 --- a/spec/modules-spec.coffee +++ b/spec/modules-spec.coffee @@ -1,9 +1,11 @@ assert = require 'assert' fs = require 'fs' path = require 'path' +temp = require 'temp' describe 'third-party module', -> fixtures = path.join __dirname, 'fixtures' + temp.track() describe 'runas', -> it 'can be required in renderer', -> @@ -15,3 +17,13 @@ describe 'third-party module', -> child.on 'message', (msg) -> assert.equal msg, 'ok' done() + + describe 'pathwatcher', -> + it 'emits file events correctly', (done) -> + pathwatcher = require 'pathwatcher' + temp.mkdir 'dir', (err, dir) -> + watcher = pathwatcher.watch dir, (event) -> + assert.equal event, 'change' + watcher.close() + done() + fs.writeFile path.join(dir, 'file'), ->