Add spec for remote setter with remote object
authorKevin Sawicki <kevinsawicki@gmail.com>
Mon, 3 Apr 2017 21:17:16 +0000 (14:17 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 4 Apr 2017 18:18:16 +0000 (11:18 -0700)
spec/api-ipc-spec.js
spec/fixtures/module/remote-object-set.js [new file with mode: 0644]

index c5e38e8..798c26d 100644 (file)
@@ -199,6 +199,14 @@ describe('ipc module', function () {
       }, /setting error/)
     })
 
+    it('can set a remote property with a remote object', function () {
+      const foo = remote.require(path.join(fixtures, 'module', 'remote-object-set.js'))
+
+      assert.doesNotThrow(function () {
+        foo.bar = remote.getCurrentWindow()
+      })
+    })
+
     it('can construct an object from its member', function () {
       var call = remote.require(path.join(fixtures, 'module', 'call.js'))
       var obj = new call.constructor()
diff --git a/spec/fixtures/module/remote-object-set.js b/spec/fixtures/module/remote-object-set.js
new file mode 100644 (file)
index 0000000..5fefbf5
--- /dev/null
@@ -0,0 +1,11 @@
+const {BrowserWindow} = require('electron')
+
+class Foo {
+  set bar (value) {
+    if (!(value instanceof BrowserWindow)) {
+      throw new Error('setting error')
+    }
+  }
+}
+
+module.exports = new Foo()