From a926829c33ca1878135000a65cf976464a4aebba Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 4 Feb 2013 08:36:15 -0800 Subject: [PATCH] Add `_.bindAll` unit test for passing just `object`. Former-commit-id: 62f90c1dc7429610fb4bfaec3c5bb64d5a63dc9e --- test/test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test.js b/test/test.js index 002a1cde9..1f3b8bfa1 100644 --- a/test/test.js +++ b/test/test.js @@ -279,6 +279,25 @@ QUnit.module('lodash.bindAll'); (function() { + test('should bind all methods of `object`', function() { + function Foo() { + this._a = 1; + this._b = 2; + this.a = function() { return this._a; }; + }; + + Foo.prototype.b = function() {return this._b; }; + + var object = new Foo; + _.bindAll(object); + + var actual = _.map(_.functions(object), function(methodName) { + return object[methodName].call({}); + }); + + deepEqual(actual, [1, 2]); + }); + test('should accept arrays of method names', function() { var object = { '_a': 1,