electron/spec/modules-spec.coffee

42 lines
1.1 KiB
CoffeeScript
Raw Normal View History

assert = require 'assert'
fs = require 'fs'
path = require 'path'
2014-01-09 12:29:54 +00:00
temp = require 'temp'
2013-12-15 16:31:40 +00:00
describe 'third-party module', ->
fixtures = path.join __dirname, 'fixtures'
2014-01-09 12:29:54 +00:00
temp.track()
describe 'runas', ->
it 'can be required in renderer', ->
require 'runas'
it 'can be required in node binary', (done) ->
runas = path.join fixtures, 'module', 'runas.js'
child = require('child_process').fork runas
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) ->
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()
fs.writeFileSync file, 'content2'
2014-01-10 07:19:08 +00:00
describe 'q', ->
Q = require 'q'
describe 'Q.when', ->
it 'emits the fullfil callback', (done) ->
Q(true).then (val) ->
assert.equal val, true
done()