From 05e76106f33ebf01661620cea5213d9f5ad04c66 Mon Sep 17 00:00:00 2001 From: Joshua Fehler Date: Tue, 26 Feb 2019 23:14:10 -0500 Subject: [PATCH] Tests: Ensure Wheel3D tests validate completion --- tests/wheel3D.spec.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/wheel3D.spec.js b/tests/wheel3D.spec.js index fc1c5a6..10bd67c 100644 --- a/tests/wheel3D.spec.js +++ b/tests/wheel3D.spec.js @@ -1,7 +1,7 @@ describe("Wheel3D", function(){ describe("When I create a new Wheel3D", function(){ describe("And I move the wheel backwards", function(){ - it("Then the active sprite should be the previous one", function(){ + it("Then the active sprite should be the previous one", function(done){ var menuList = []; for (var i = 0; i < 4; i++) { var dummySprite = game.add.sprite(0, 0, "dummySprite"); @@ -18,12 +18,23 @@ describe("Wheel3D", function(){ {"x":0, "y": -90, "z": 0} ); + var isDone = false; + wheel.onComplete.add( function (wheel) { - chai.expect(wheel.active).to.equal(wheel.wheelItems[3]); + isDone = true; }); wheel.activate(); wheel.moveBack(); + + setTimeout( function () { + try { + chai.expect(isDone).to.equal(true); + done(); + } catch(err) { + done(err); + } + }, 500 ); }); }); describe("And I move the wheel forward", function(){ @@ -44,12 +55,24 @@ describe("Wheel3D", function(){ {"x":0, "y": -90, "z": 0} ); + var isDone = false; + wheel.onComplete.add( function (wheel) { - chai.expect(wheel.active).to.equal(wheel.wheelItems[1]); + isDone = true; }); wheel.activate(); wheel.moveForward(); + + setTimeout( function () { + try { + chai.expect(isDone).to.equal(true); + done(); + } catch(err) { + done(err); + } + }, 500 ); + }); }); });