Skip to content

Commit

Permalink
Fix test (elastic#9720)
Browse files Browse the repository at this point in the history
Backports PR elastic#9448

The assertion to determine skipping was wrong. This almost always returned true.
  • Loading branch information
elastic-jasper authored and thomasneirynck committed Jan 4, 2017
1 parent 20825a2 commit ed55995
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/core_plugins/tagcloud/public/__tests__/tag_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,12 @@ describe('tag cloud tests', function () {


const centered = (largest[1] === 0 && largest[2] === 0);
const halfWidth = debugInfo.size.width / 2;
const halfHeight = debugInfo.size.height / 2;
const inside = debugInfo.positions.filter(position => {
return debugInfo.size[0] <= position[1] && position[1] <= debugInfo.size[0]
&& debugInfo.size[1] <= position[2] && position[2] <= debugInfo.size[1];
const x = position.x + halfWidth;
const y = position.y + halfHeight;
return 0 <= x && x <= debugInfo.size.width && 0 <= y && y <= debugInfo.size.height;
});

return centered && inside.length === count - 1;
Expand All @@ -452,7 +455,6 @@ describe('tag cloud tests', function () {
function handleExpectedBlip(assertion) {
return function () {
if (!shouldAssert()) {
console.warn('Skipping assertion.');
return;
}
assertion();
Expand Down
14 changes: 12 additions & 2 deletions src/core_plugins/tagcloud/public/tag_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,18 @@ class TagCloud extends EventEmitter {
*/
getDebugInfo() {
const debug = {};
debug.positions = this._currentJob ? this._currentJob.words.map(tag => [tag.text, tag.x, tag.y, tag.rotate]) : [];
debug.size = this._size.slice();
debug.positions = this._currentJob ? this._currentJob.words.map(tag => {
return {
text: tag.text,
x: tag.x,
y: tag.y,
rotate: tag.rotate
};
}) : [];
debug.size = {
width: this._size[0],
height: this._size[1]
};
return debug;
}

Expand Down

0 comments on commit ed55995

Please sign in to comment.