2013-12-06 14:23:02 +00:00
|
|
|
assert = require 'assert'
|
|
|
|
fs = require 'fs'
|
|
|
|
path = require 'path'
|
2014-01-09 12:29:54 +00:00
|
|
|
temp = require 'temp'
|
2013-12-06 14:23:02 +00:00
|
|
|
|
2013-12-15 16:31:40 +00:00
|
|
|
describe 'third-party module', ->
|
2013-12-06 14:23:02 +00:00
|
|
|
fixtures = path.join __dirname, 'fixtures'
|
2014-01-09 12:29:54 +00:00
|
|
|
temp.track()
|
2013-12-06 14:23:02 +00:00
|
|
|
|
2013-12-17 04:00:21 +00:00
|
|
|
describe 'runas', ->
|
2013-12-06 14:23:02 +00:00
|
|
|
it 'can be required in renderer', ->
|
2013-12-17 04:00:21 +00:00
|
|
|
require 'runas'
|
2013-12-06 14:23:02 +00:00
|
|
|
|
|
|
|
it 'can be required in node binary', (done) ->
|
2013-12-17 04:00:21 +00:00
|
|
|
runas = path.join fixtures, 'module', 'runas.js'
|
|
|
|
child = require('child_process').fork runas
|
2013-12-06 14:23:02 +00:00
|
|
|
child.on 'message', (msg) ->
|
|
|
|
assert.equal msg, 'ok'
|
|
|
|
done()
|
2014-01-09 12:29:54 +00:00
|
|
|
|
|
|
|
describe 'pathwatcher', ->
|
|
|
|
it 'emits file events correctly', (done) ->
|
|
|
|
pathwatcher = require 'pathwatcher'
|
|
|
|
temp.mkdir 'dir', (err, dir) ->
|
2014-01-09 14:13:48 +00:00
|
|
|
assert err == null
|
|
|
|
file = path.join dir, 'file'
|
|
|
|
fs.writeFileSync file, 'content'
|
|
|
|
watcher = pathwatcher.watch file, (event) ->
|
2014-01-09 12:29:54 +00:00
|
|
|
assert.equal event, 'change'
|
|
|
|
watcher.close()
|
|
|
|
done()
|
2014-01-09 14:13:48 +00:00
|
|
|
fs.writeFileSync file, 'content2'
|