diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-11-20 06:45:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-11-20 06:45:41 +0000 |
commit | 9d45e42dc0298ea8241132142d3100358fe99dc4 (patch) | |
tree | 8435105a23089a82f8298490dff6e3e4218930b4 /tests/bind.js | |
parent | Initial commit. (diff) | |
download | decko-9d45e42dc0298ea8241132142d3100358fe99dc4.tar.xz decko-9d45e42dc0298ea8241132142d3100358fe99dc4.zip |
Adding upstream version 1.2.0.upstream/1.2.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/bind.js')
-rw-r--r-- | tests/bind.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/bind.js b/tests/bind.js new file mode 100644 index 0000000..c76a0f4 --- /dev/null +++ b/tests/bind.js @@ -0,0 +1,37 @@ +import { bind } from '..'; +import { expect } from 'chai'; + +/*global describe,it*/ + +describe('bind()', () => { + it('should bind when used as a simple decorator', next => { + let c = { + @bind + foo() { + return this; + } + }; + + expect(c.foo()).to.equal(c); + + let p = c.foo; + expect(p()).to.equal(c); + + let a = {}; + expect(c.foo.call(a)).to.equal(c); + + next(); + }); + + it('should bind when used as a function', next => { + let ctx = {}, + c = bind(function(){ return this; }, ctx); + + expect(c()).to.equal(ctx); + + let a = {}; + expect(c.call(a)).to.equal(ctx); + + next(); + }); +}); |