Browse Source

Add spec for remote callback length

Kevin Sawicki 8 years ago
parent
commit
6b56dfd94b
2 changed files with 10 additions and 0 deletions
  1. 7 0
      spec/api-ipc-spec.js
  2. 3 0
      spec/fixtures/module/function-with-args.js

+ 7 - 0
spec/api-ipc-spec.js

@@ -85,6 +85,13 @@ describe('ipc module', function () {
       assert.equal(foo.baz(), 123)
     })
 
+    it('includes the length of functions specified as arguments', function () {
+      var a = remote.require(path.join(fixtures, 'module', 'function-with-args.js'))
+      assert.equal(a(function (a, b, c, d, f) {}), 5)
+      assert.equal(a((a) => {}), 1)
+      assert.equal(a((...args) => {}), 0)
+    })
+
     it('handles circular references in arrays and objects', function () {
       var a = remote.require(path.join(fixtures, 'module', 'circular.js'))
 

+ 3 - 0
spec/fixtures/module/function-with-args.js

@@ -0,0 +1,3 @@
+module.exports = function (cb) {
+  return cb.length
+}