41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
define(["require", "exports", "./appendFunction"], function (require, exports, appendFunction_1) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
describe('appendFunction', function () {
|
|
it('can append 2 functions', function () {
|
|
var counter = 0;
|
|
var function1 = function () { return counter++; };
|
|
var function2 = function () { return counter++; };
|
|
var function3 = (0, appendFunction_1.appendFunction)({}, function1, function2);
|
|
function3();
|
|
expect(counter).toEqual(2);
|
|
});
|
|
it('can deal with falsey values', function () {
|
|
var counter = 0;
|
|
var function1 = function () { return counter++; };
|
|
var function2 = function () { return counter++; };
|
|
var function3 = (0, appendFunction_1.appendFunction)({}, function1, undefined, null, function2);
|
|
function3();
|
|
expect(counter).toEqual(2);
|
|
});
|
|
it('preserves the parent', function () {
|
|
function add() {
|
|
this.counter++;
|
|
}
|
|
var Foo = /** @class */ (function () {
|
|
function Foo() {
|
|
this.counter = 0;
|
|
this.add = (0, appendFunction_1.appendFunction)(this, add, this.add);
|
|
}
|
|
Foo.prototype.add = function () {
|
|
this.counter++;
|
|
};
|
|
return Foo;
|
|
}());
|
|
var foo = new Foo();
|
|
foo.add();
|
|
expect(foo.counter).toEqual(2);
|
|
});
|
|
});
|
|
});
|
|
//# sourceMappingURL=appendFunction.test.js.map
|