Backports PR #9448

The assertion to determine skipping was wrong. This almost always returned true.
This commit is contained in:
jasper 2017-01-04 12:07:22 -05:00 committed by Thomas Neirynck
parent 672db67f72
commit 15ad03f4b4
2 changed files with 17 additions and 5 deletions

View file

@ -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;
@ -452,7 +455,6 @@ describe('tag cloud tests', function () {
function handleExpectedBlip(assertion) {
return function () {
if (!shouldAssert()) {
console.warn('Skipping assertion.');
return;
}
assertion();

View file

@ -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;
}