Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit ad55ed0

Browse files
committed
fix(image): use default scale factor if passed value is not positive
1 parent ca7fa56 commit ad55ed0

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/image/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ module.exports = class Image {
5858
return this;
5959
}
6060

61-
_scale(area, scaleFactor = 1) {
61+
_scale(area, scaleFactor) {
62+
scaleFactor = scaleFactor || 1;
63+
6264
return {
6365
left: area.left * scaleFactor,
6466
top: area.top * scaleFactor,

test/lib/image/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ describe('Image', () => {
5454
.then(() => assert.calledWith(SafeRect.create, scaledRect));
5555
});
5656

57+
it('should use default scale factor (one) if the passed value is not positive', () => {
58+
const rect = {left: 1, top: 2, width: 3, height: 4};
59+
60+
return image.crop(rect, {scaleFactor: null})
61+
.then(() => assert.calledWith(SafeRect.create, rect));
62+
});
63+
5764
it('should crop an image', () => {
5865
SafeRect.create.returns({left: 1, top: 2, width: 3, height: 4});
5966

0 commit comments

Comments
 (0)