Skip to content

Commit

Permalink
Fixed incorrect context in fastdom-promised
Browse files Browse the repository at this point in the history
Fixes issue #81
  • Loading branch information
dylanchapman authored and wilsonpage committed May 4, 2016
1 parent 8d9e20f commit bfc83e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
@@ -1,20 +1,21 @@
sudo: true
language: node_js

node_js:
- 5.1.0

addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable

before_script:
- export CHROME_BIN=$(which google-chrome-stable)
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sudo add-apt-repository -y ppa:canonical-chromium-builds/stage
- sudo apt-get update -y
- sudo apt-get install -y chromium-browser
- echo $(which chromium-browser)
- echo $(which chromium)
- export CHROME_BIN=$(which chromium-browser)
- export DISPLAY=:99.0

after_script:
- npm run coveralls
2 changes: 1 addition & 1 deletion extensions/fastdom-promised.js
Expand Up @@ -60,7 +60,7 @@ function create(promised, type, fn, ctx) {
var promise = new Promise(function(resolve, reject) {
task = fastdom[type](function() {
tasks.delete(promise);
try { resolve(fn()); }
try { resolve(ctx ? fn.call(ctx) : fn()); }
catch (e) { reject(e); }
}, ctx);
});
Expand Down
10 changes: 10 additions & 0 deletions test/fastdom-promised-test.js
Expand Up @@ -45,4 +45,14 @@ suite('fastdom-promised', function() {
done();
});
});

test('it calls callback with given context', function() {
var spy = sinon.spy();
var ctx = {};

return fastdom.measure(spy, ctx)
.then(function() {
sinon.assert.calledOn(spy, ctx);
});
});
});

0 comments on commit bfc83e2

Please sign in to comment.