From 251b070db314c5c7e13fd389f69bf78eb2adc55c Mon Sep 17 00:00:00 2001 From: Ryan Jones Date: Tue, 29 Nov 2016 11:50:11 -0800 Subject: [PATCH] add unit test --- scripts/developer/tests/bindUnitTest.js | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/developer/tests/bindUnitTest.js diff --git a/scripts/developer/tests/bindUnitTest.js b/scripts/developer/tests/bindUnitTest.js new file mode 100644 index 0000000000..38c2fb350f --- /dev/null +++ b/scripts/developer/tests/bindUnitTest.js @@ -0,0 +1,31 @@ +Script.include('../libraries/jasmine/jasmine.js'); +Script.include('../libraries/jasmine/hifi-boot.js'); +Script.include('../../system/libraries/utils.js'); + +describe('Bind', function() { + it('functions should have bind available', function() { + var foo = 'bar'; + + function callAnotherFn(anotherFn) { + return anotherFn(); + } + + function TestConstructor() { + this.foo = foo; + } + + TestConstructor.prototype.doSomething = function() { + return callAnotherFn(function() { + return this.foo; + }.bind(this)); + } + + var instance = new TestConstructor(); + + expect(typeof(instance.doSomething.bind) !== 'undefined'); + expect(instance.doSomething()).toEqual(foo); + }); +}); + +jasmine.getEnv().execute(); +Script.stop(); \ No newline at end of file