mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 06:55:16 +02:00
32 lines
805 B
JavaScript
32 lines
805 B
JavaScript
/* 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);
|
|
});
|
|
});
|