From 511b2a442225f4921750d966bad14f1789521776 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 26 Jul 2013 15:53:00 +0800 Subject: [PATCH] Add test for id property of remote object. --- spec/api/ipc.coffee | 14 ++++++++++++++ spec/fixtures/module/id.js | 1 + spec/main.js | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 spec/fixtures/module/id.js diff --git a/spec/api/ipc.coffee b/spec/api/ipc.coffee index b3482185e855..4860b96257cb 100644 --- a/spec/api/ipc.coffee +++ b/spec/api/ipc.coffee @@ -1,4 +1,6 @@ assert = require 'assert' +ipc = require 'ipc' +path = require 'path' remote = require 'remote' describe 'ipc', -> @@ -7,3 +9,15 @@ describe 'ipc', -> dialog1 = remote.require 'dialog' dialog2 = remote.require 'dialog' assert.equal dialog1, dialog2 + + it 'should work when object contains id property', -> + a = remote.require path.join(__dirname, '..', 'fixtures', 'module', 'id.js') + assert.equal a.id, 1127 + + 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 diff --git a/spec/fixtures/module/id.js b/spec/fixtures/module/id.js new file mode 100644 index 000000000000..2faec9d38321 --- /dev/null +++ b/spec/fixtures/module/id.js @@ -0,0 +1 @@ +exports.id = 1127 diff --git a/spec/main.js b/spec/main.js index b3b4b4dac0e8..9439ce155d61 100644 --- a/spec/main.js +++ b/spec/main.js @@ -1,8 +1,13 @@ var app = require('app'); +var ipc = require('ipc'); var BrowserWindow = require('browser-window'); var window = null; +ipc.on('message', function() { + ipc.send.apply(this, arguments); +}); + process.on('uncaughtException', function() { window.openDevTools(); });