aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/options/restore.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/cropperjs/test/specs/options/restore.spec.js')
-rw-r--r--library/cropperjs/test/specs/options/restore.spec.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/library/cropperjs/test/specs/options/restore.spec.js b/library/cropperjs/test/specs/options/restore.spec.js
new file mode 100644
index 000000000..3a011edc8
--- /dev/null
+++ b/library/cropperjs/test/specs/options/restore.spec.js
@@ -0,0 +1,38 @@
+describe('restore (option)', () => {
+ it('should restore the cropped area after resize the window be default', (done) => {
+ const image = window.createImage();
+ const cropper = new Cropper(image, {
+ ready() {
+ const data = cropper.zoomTo(1).getData(true);
+ const containerData = cropper.getContainerData();
+
+ image.parentElement.style.width = `${containerData.width - 10}px`;
+ image.parentElement.style.height = `${containerData.height - 10}px`;
+ window.dispatchEvent(window.createEvent('resize'));
+ expect(cropper.getData(true)).to.deep.equal(data);
+ done();
+ },
+ });
+
+ expect(cropper.options.restore).to.be.true;
+ });
+
+ it('should not be restore', (done) => {
+ const image = window.createImage();
+ const cropper = new Cropper(image, {
+ restore: false,
+
+ ready() {
+ const data = cropper.zoomTo(1).getData(true);
+ const containerData = cropper.getContainerData();
+
+ image.parentElement.style.width = `${containerData.width / 2}px`;
+ window.dispatchEvent(window.createEvent('resize'));
+ expect(cropper.getData(true)).to.not.deep.equal(data);
+ done();
+ },
+ });
+
+ expect(cropper.options.restore).to.be.false;
+ });
+});