Skip to content

Commit 0fdc7ae

Browse files
Fix bind example test
The current bind example test will succeed even without using `@bind`. This is because of the way that `e.foo` is being called in the example test. When it is called like `e.foo()`, the `e` is to the left of the dot, so `e` is passed in as the `this` argument to the `foo` function. So the test `assert.equal(e.foo(), e)` will be `true` regardless of whether `@bind` is used. To fix this, we can change the test to `assert.equal(e.call(null), e)` to explicitly pass in `null` as the `this` argument for `foo` using `Function.prototype.call`.
1 parent 660ead2 commit 0fdc7ae

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Example {
4343
}
4444

4545
let e = new Example();
46-
assert.equal(e.foo(), e);
46+
assert.equal(e.foo.call(null), e);
4747
```
4848

4949

0 commit comments

Comments
 (0)