32 lines · 805 B · JavaScript
RawDownload
/* eslint-env jasmine */ Script.include('../../../system/libraries/utils.js'); describe('Bind', function() {    it('exists for functions', function() {        var FUNC = 'function';        expect(typeof(function() {}.bind)).toEqual(FUNC);    });     it('should allow for setting context of this', 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(instance.doSomething()).toEqual(foo);    });});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t