From 9151b5edd6c55e33a924adede9f2e540b21a3efc Mon Sep 17 00:00:00 2001 From: Fabian Elsner Date: Tue, 2 Oct 2018 16:36:26 +0200 Subject: [PATCH] Fix scale container test to load image async --- test/utils/ScaleContainer.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/utils/ScaleContainer.js b/test/utils/ScaleContainer.js index dc370e7..7ac27b9 100644 --- a/test/utils/ScaleContainer.js +++ b/test/utils/ScaleContainer.js @@ -8,12 +8,18 @@ describe("test scalable/tilable container", function() { }).throw(); }); - it("make sure calculations are correct", function() { + it("make sure calculations are correct", async function() { + var image = new Image(); - var loader = GOWN.loader; + async function loadImage(){ + return new Promise(function(resolve, reject){ + image.onload = resolve; + image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAIAAAAmdTLBAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wMCCxAuWFRGfgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAOElEQVQ4y2P8z4APMP6HYJyAiYEyMKp/ZOtnYWDAl7z+MzDiTX4MjP8bGvBIN9ZD8Gj4j+qniX4AnXcKKJynPUsAAAAASUVORK5CYII="; + }) + } + + await loadImage() - var image = new Image(); - image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAIAAAAmdTLBAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wMCCxAuWFRGfgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAOElEQVQ4y2P8z4APMP6HYJyAiYEyMKp/ZOtnYWDAl7z+MzDiTX4MjP8bGvBIN9ZD8Gj4j+qniX4AnXcKKJynPUsAAAAASUVORK5CYII="; var baseTexture = new PIXI.BaseTexture(image); var texture = new PIXI.Texture(baseTexture); @@ -39,7 +45,6 @@ describe("test scalable/tilable container", function() { expect(scale.cm.width).equal(80); expect(scale.cm.height).equal(180); - //TODO: also use imagediff to check images });