From bfc83e219abee040a2c4ec988febf3cb81816656 Mon Sep 17 00:00:00 2001 From: dylanchapman Date: Tue, 3 May 2016 11:54:53 -0500 Subject: [PATCH] Fixed incorrect context in fastdom-promised Fixes issue #81 --- .travis.yml | 15 ++++++++------- extensions/fastdom-promised.js | 2 +- test/fastdom-promised-test.js | 10 ++++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ed9373..734da09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: true language: node_js node_js: @@ -5,16 +6,16 @@ node_js: 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 diff --git a/extensions/fastdom-promised.js b/extensions/fastdom-promised.js index e002072..1d0868f 100644 --- a/extensions/fastdom-promised.js +++ b/extensions/fastdom-promised.js @@ -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); }); diff --git a/test/fastdom-promised-test.js b/test/fastdom-promised-test.js index 959800e..f1e95dd 100644 --- a/test/fastdom-promised-test.js +++ b/test/fastdom-promised-test.js @@ -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); + }); + }); });