From 40234e8e41db709e99cb861b291ec49bf7abd413 Mon Sep 17 00:00:00 2001 From: ppisljar Date: Wed, 21 Sep 2016 09:21:01 +0200 Subject: [PATCH] fixing tests --- .../vislib_vis_type/__tests__/_vislib_renderbot.js | 9 +++++---- src/ui/public/vislib_vis_type/vislib_renderbot.js | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js b/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js index b70e61001a9e4..7d0a3fd3c3cf3 100644 --- a/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js +++ b/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js @@ -134,10 +134,11 @@ describe('renderbot', function exportWrapper() { let buildStub = sinon.stub(renderbot, 'buildChartData', _.constant(football)); let renderStub = sinon.stub(renderbot.vislibVis, 'render'); - renderbot.render('flat data', persistedState); - expect(renderStub.callCount).to.be(1); - expect(buildStub.callCount).to.be(1); - expect(renderStub.firstCall.args[0]).to.be(football); + renderbot.render('flat data', persistedState).then(() => { + expect(renderStub.callCount).to.be(1); + expect(buildStub.callCount).to.be(1); + expect(renderStub.firstCall.args[0]).to.be(football); + }); }); }); diff --git a/src/ui/public/vislib_vis_type/vislib_renderbot.js b/src/ui/public/vislib_vis_type/vislib_renderbot.js index 4b71e48c4bcae..8ef87c0ed7f1b 100644 --- a/src/ui/public/vislib_vis_type/vislib_renderbot.js +++ b/src/ui/public/vislib_vis_type/vislib_renderbot.js @@ -46,9 +46,11 @@ module.exports = function VislibRenderbotFactory(Private) { VislibRenderbot.prototype.buildChartData = buildChartData; VislibRenderbot.prototype.render = function (esResponse) { this.chartData = this.buildChartData(esResponse); - // to allow legend to render first - setTimeout(() => { - this.vislibVis.render(this.chartData, this.uiState); + // to allow legend to render first (wait for angular digest cycle to complete) + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(this.vislibVis.render(this.chartData, this.uiState)); + }); }); };