2013-07-23 03:59:07 +00:00
|
|
|
assert = require 'assert'
|
2013-07-26 07:53:00 +00:00
|
|
|
ipc = require 'ipc'
|
|
|
|
path = require 'path'
|
2013-07-23 03:59:07 +00:00
|
|
|
remote = require 'remote'
|
|
|
|
|
|
|
|
describe 'ipc', ->
|
2013-08-14 05:27:50 +00:00
|
|
|
fixtures = path.join __dirname, '..', 'fixtures'
|
|
|
|
|
2013-07-23 03:59:07 +00:00
|
|
|
describe 'remote.require', ->
|
|
|
|
it 'should returns same object for the same module', ->
|
|
|
|
dialog1 = remote.require 'dialog'
|
|
|
|
dialog2 = remote.require 'dialog'
|
|
|
|
assert.equal dialog1, dialog2
|
2013-07-26 07:53:00 +00:00
|
|
|
|
|
|
|
it 'should work when object contains id property', ->
|
2013-08-14 05:27:50 +00:00
|
|
|
a = remote.require path.join(fixtures, 'module', 'id.js')
|
2013-07-26 07:53:00 +00:00
|
|
|
assert.equal a.id, 1127
|
|
|
|
|
2013-08-14 05:27:50 +00:00
|
|
|
describe 'remote object', ->
|
|
|
|
it 'can change its properties', ->
|
|
|
|
property = remote.require path.join(fixtures, 'module', 'property.js')
|
|
|
|
assert.equal property.property, 1127
|
|
|
|
property.property = 1007
|
|
|
|
assert.equal property.property, 1007
|
|
|
|
property2 = remote.require path.join(fixtures, 'module', 'property.js')
|
|
|
|
assert.equal property2.property, 1007
|
|
|
|
|
2013-08-14 13:19:26 +00:00
|
|
|
# Restore.
|
|
|
|
property.property = 1127
|
|
|
|
|
2013-07-26 07:53:00 +00:00
|
|
|
describe 'ipc.send', ->
|
|
|
|
it 'should work when sending an object containing id property', (done) ->
|
|
|
|
obj = id: 1, name: 'ly'
|
|
|
|
ipc.on 'message', (message) ->
|
|
|
|
assert.deepEqual message, obj
|
|
|
|
done()
|
|
|
|
ipc.send obj
|