Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Sep 21, 2016
1 parent f7f0f12 commit 40234e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

Expand Down
8 changes: 5 additions & 3 deletions src/ui/public/vislib_vis_type/vislib_renderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});
};

Expand Down

0 comments on commit 40234e8

Please sign in to comment.