From 2e23a571d6485838415c7bcf8ef0125e2ec9d4cf Mon Sep 17 00:00:00 2001 From: Graeme Yeates Date: Thu, 10 Jul 2014 13:22:31 -0400 Subject: [PATCH] Add bind-shim test coverage --- test/functions.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/functions.js b/test/functions.js index de2be68e7..5a9f0a6d9 100644 --- a/test/functions.js +++ b/test/functions.js @@ -2,7 +2,7 @@ module('Functions'); - test('bind', function() { + var bindSpec = function() { var context = {name : 'moe'}; var func = function(arg) { return 'name: ' + (this.name || arg); }; var bound = _.bind(func, context); @@ -40,7 +40,15 @@ ok(newBoundf instanceof F, 'a bound instance is an instance of the original function'); raises(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function'); - }); + }; + + var bind = Function.prototype.bind; + if (bind) { + test('bind with Function.prototype.bind', bindSpec); + Function.prototype.bind = null; + } + test('bind without Function.prototype.bind', bindSpec); + // Function.prototype.bind = bind; // phantom js breaks if you do this ??? test('partial', function() { var obj = {name: 'moe'};