Skip to content

Commit

Permalink
Tests: expect ranges for flaky text test
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Nov 4, 2023
1 parent bdcf026 commit 7c1551b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test/unit/text.js
Expand Up @@ -44,13 +44,11 @@ describe('Text to image', function () {

it('text with width and height', function (done) {
const output = fixtures.path('output.text-width-height.png');
const maxWidth = 500;
const maxHeight = 500;
const text = sharp({
text: {
text: 'Hello, world!',
width: maxWidth,
height: maxHeight
width: 500,
height: 400
}
});
if (!sharp.versions.pango) {
Expand All @@ -60,9 +58,9 @@ describe('Text to image', function () {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(3, info.channels);
assert.ok(inRange(info.width, 1, maxWidth + 5), `Actual width ${info.width}`);
assert.ok(inRange(info.height, 1, maxHeight + 5), `Actual height ${info.height}`);
assert.ok(info.textAutofitDpi > 0);
assert.ok(inRange(info.width, 450, 550), `Actual width ${info.width}`);
assert.ok(inRange(info.height, 300, 450), `Actual height ${info.height}`);
assert.ok(inRange(info.textAutofitDpi, 900, 1200), `Actual textAutofitDpi ${info.textAutofitDpi}`);
done();
});
});
Expand Down

0 comments on commit 7c1551b

Please sign in to comment.