From 941745cd066dab152f6e32d83b074a069ff19ce0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 3 Jan 2016 22:18:18 -0600 Subject: [PATCH] Add `_.cond` test for `this` binding. --- test/test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test.js b/test/test.js index aa91767d6..d769af10d 100644 --- a/test/test.js +++ b/test/test.js @@ -2849,6 +2849,17 @@ assert.raises(function() { _.cond([[alwaysTrue, value]])(); }, TypeError); }); }); + + QUnit.test('should use `this` binding of function for `pairs`', function(assert) { + assert.expect(1); + + var cond = _.cond([ + [function(a) { return this[a]; }, function(a, b) { return this[b]; }] + ]); + + var object = { 'cond': cond, 'a': 1, 'b': 2 }; + assert.strictEqual(object.cond('a', 'b'), 2); + }); }()); /*--------------------------------------------------------------------------*/