From 5482ac350aab728585277fe4b6835e947fdc2cd5 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 16 Sep 2018 22:51:51 +0200 Subject: [PATCH] Try to fix node 10 unit test (#5235) * fixed * removed node 9 --- .travis.yml | 4 +--- test/unit/object.js | 21 ++------------------- test/unit/util.js | 11 +++++++---- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index d3cdfb7c..cd3d8207 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,10 +64,8 @@ jobs: apt: packages: # avoid installing packages - stage: Unit Tests - env: LAUNCHER=Node CANFAIL=TRUE + env: LAUNCHER=Node node_js: "10" - - stage: Unit Tests - node_js: "9" - stage: Unit Tests node_js: "8" - stage: Unit Tests diff --git a/test/unit/object.js b/test/unit/object.js index cd3ddb10..28b9c47a 100644 --- a/test/unit/object.js +++ b/test/unit/object.js @@ -26,25 +26,8 @@ var elImage = _createImageElement(); elImage.width = IMG_WIDTH; elImage.height = IMG_HEIGHT; - setSrc(elImage, IMG_SRC, function() { - callback(elImage); - }); - } - - function setSrc(img, src, callback) { - if (fabric.isLikelyNode) { - require('fs').readFile(src, function(err, imgData) { - if (err) { - throw err; - }; - img.src = imgData; - callback && callback(); - }); - } - else { - img.src = src; - callback && callback(); - } + elImage.onload = callback; + elImage.src = IMG_SRC; } QUnit.module('fabric.Object', { diff --git a/test/unit/util.js b/test/unit/util.js index 095e0b6f..f8e497c1 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -483,10 +483,13 @@ QUnit.test('fabric.util.loadImage with url for a non exsiting image', function(assert) { var done = assert.async(); - fabric.util.loadImage(IMG_URL_NON_EXISTING, function(img, error) { - assert.equal(error, true, 'callback should be invoked with error set to true'); - done(); - }); + try { + fabric.util.loadImage(IMG_URL_NON_EXISTING, function(img, error) { + assert.equal(error, true, 'callback should be invoked with error set to true'); + done(); + }, this); + } + catch (e) { } }); var SVG_WITH_1_ELEMENT = '\