-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3193 from AlchemyCMS/backport/7.4-stable/pr-3192
[7.4-stable] Fix image cropper
- Loading branch information
Showing
4 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import ImageCropper from "alchemy_admin/image_cropper" | ||
|
||
describe("ImageCropper", () => { | ||
describe("cropperOptions", () => { | ||
beforeEach(() => { | ||
document.body.innerHTML = ` | ||
<div id="element_id"> | ||
<input id="crop_from" type="hidden" value="0x423" /> | ||
<input id="crop_size" type="hidden" value="1200x480" /> | ||
</div> | ||
` | ||
Alchemy.currentDialog = jest.fn() | ||
}) | ||
|
||
it("is sets initial data", () => { | ||
const image = new Image() | ||
const cropper = new ImageCropper( | ||
image, | ||
{}, | ||
1, | ||
["crop_from", "crop_size"], | ||
"element_id" | ||
) | ||
expect(cropper.cropperOptions["data"]).toEqual({ | ||
height: 480, | ||
width: 1200, | ||
x: 0, | ||
y: 423 | ||
}) | ||
}) | ||
|
||
it("does not set min crop size", () => { | ||
const image = new Image() | ||
const cropper = new ImageCropper( | ||
image, | ||
{}, | ||
1, | ||
["crop_from", "crop_size"], | ||
"element_id" | ||
) | ||
expect(cropper.cropperOptions["minCropBoxWidth"]).toBeUndefined() | ||
expect(cropper.cropperOptions["minCropBoxHeight"]).toBeUndefined() | ||
}) | ||
|
||
it("prevents CORS issues", () => { | ||
const image = new Image() | ||
const cropper = new ImageCropper( | ||
image, | ||
{}, | ||
1, | ||
["crop_from", "crop_size"], | ||
"element_id" | ||
) | ||
expect(cropper.cropperOptions["checkCrossOrigin"]).toBe(false) | ||
expect(cropper.cropperOptions["checkOrientation"]).toBe(false) | ||
}) | ||
}) | ||
}) |