aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/methods
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-01-24 11:17:25 +0100
committerMario Vavti <mario@mariovavti.com>2018-01-24 11:17:25 +0100
commit503b2225f03c5ffe663e4e0955b25daa1bd19cf4 (patch)
tree666488330ddaeeb02bff5bd674534972aabc69b4 /library/cropperjs/test/methods
parente3a6b0012e95aae8e0572a53ea96ddc915d6eb03 (diff)
parent304085606fac6ae4fd2d3e29ed44afb4b4e1bc28 (diff)
downloadvolse-hubzilla-503b2225f03c5ffe663e4e0955b25daa1bd19cf4.tar.gz
volse-hubzilla-503b2225f03c5ffe663e4e0955b25daa1bd19cf4.tar.bz2
volse-hubzilla-503b2225f03c5ffe663e4e0955b25daa1bd19cf4.zip
Merge remote-tracking branch 'mike/master' into dev
Diffstat (limited to 'library/cropperjs/test/methods')
-rw-r--r--library/cropperjs/test/methods/clear.js29
-rw-r--r--library/cropperjs/test/methods/crop.js24
-rw-r--r--library/cropperjs/test/methods/destroy.js22
-rw-r--r--library/cropperjs/test/methods/disable.js60
-rw-r--r--library/cropperjs/test/methods/enable.js23
-rw-r--r--library/cropperjs/test/methods/getCanvasData.js23
-rw-r--r--library/cropperjs/test/methods/getContainerData.js19
-rw-r--r--library/cropperjs/test/methods/getCropBoxData.js21
-rw-r--r--library/cropperjs/test/methods/getCroppedCanvas.js33
-rw-r--r--library/cropperjs/test/methods/getData.js46
-rw-r--r--library/cropperjs/test/methods/getImageData.js31
-rw-r--r--library/cropperjs/test/methods/move.js20
-rw-r--r--library/cropperjs/test/methods/moveTo.js19
-rw-r--r--library/cropperjs/test/methods/replace.js23
-rw-r--r--library/cropperjs/test/methods/reset.js35
-rw-r--r--library/cropperjs/test/methods/rotate.js19
-rw-r--r--library/cropperjs/test/methods/rotateTo.js20
-rw-r--r--library/cropperjs/test/methods/scale.js19
-rw-r--r--library/cropperjs/test/methods/scaleX.js18
-rw-r--r--library/cropperjs/test/methods/scaleY.js18
-rw-r--r--library/cropperjs/test/methods/setAspectRatio.js20
-rw-r--r--library/cropperjs/test/methods/setCanvasData.js34
-rw-r--r--library/cropperjs/test/methods/setCropBoxData.js36
-rw-r--r--library/cropperjs/test/methods/setData.js36
-rw-r--r--library/cropperjs/test/methods/setDragMode.js27
-rw-r--r--library/cropperjs/test/methods/zoom.js20
-rw-r--r--library/cropperjs/test/methods/zoomTo.js21
27 files changed, 716 insertions, 0 deletions
diff --git a/library/cropperjs/test/methods/clear.js b/library/cropperjs/test/methods/clear.js
new file mode 100644
index 000000000..6510ebad2
--- /dev/null
+++ b/library/cropperjs/test/methods/clear.js
@@ -0,0 +1,29 @@
+QUnit.test('methods#clear', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+
+ cropper.clear();
+ assert.notOk(cropper.cropped);
+ assert.deepEqual(cropper.getData(), {
+ x: 0,
+ y: 0,
+ width: 0,
+ height: 0,
+ rotate: 0,
+ scaleX: 1,
+ scaleY: 1
+ });
+ assert.deepEqual(cropper.getCropBoxData(), {});
+ assert.ok(util.hasClass(cropper.cropBox, 'cropper-hidden'));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/crop.js b/library/cropperjs/test/methods/crop.js
new file mode 100644
index 000000000..e4ae679f1
--- /dev/null
+++ b/library/cropperjs/test/methods/crop.js
@@ -0,0 +1,24 @@
+QUnit.test('methods#crop', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ autoCrop: false,
+
+ ready: function () {
+ var cropper = this.cropper;
+
+ assert.notOk(cropper.cropped);
+ assert.ok(util.hasClass(cropper.cropBox, 'cropper-hidden'));
+
+ cropper.crop();
+ assert.ok(cropper.cropped);
+ assert.notOk(util.hasClass(cropper.cropBox, 'cropper-hidden'));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/destroy.js b/library/cropperjs/test/methods/destroy.js
new file mode 100644
index 000000000..cb65e0696
--- /dev/null
+++ b/library/cropperjs/test/methods/destroy.js
@@ -0,0 +1,22 @@
+QUnit.test('methods#destroy', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+
+ assert.ok(typeof cropper === 'object');
+ assert.ok(util.hasClass(image, 'cropper-hidden'));
+
+ cropper.destroy();
+ assert.ok(typeof this.cropper === 'undefined');
+ assert.notOk(util.hasClass(image, 'cropper-hidden'));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/disable.js b/library/cropperjs/test/methods/disable.js
new file mode 100644
index 000000000..c87f7aa91
--- /dev/null
+++ b/library/cropperjs/test/methods/disable.js
@@ -0,0 +1,60 @@
+QUnit.test('methods#disable', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(11);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var options = cropper.options;
+ var cropBoxData;
+ var canvasData;
+ var imageData;
+ var action;
+
+ cropper.disable();
+ assert.ok(cropper.disabled);
+ assert.ok(util.hasClass(cropper.cropper, 'cropper-disabled'));
+
+ cropBoxData = cropper.getCropBoxData();
+ cropper.clear();
+ assert.deepEqual(cropper.getCropBoxData(), cropBoxData);
+
+ imageData = cropper.getImageData();
+ cropper.move(10, 10);
+ assert.deepEqual(cropper.getImageData(), imageData);
+
+ cropper.zoom(0.5);
+ assert.strictEqual(cropper.getImageData().ratio, imageData.ratio);
+
+ cropper.rotate(15);
+ assert.strictEqual(cropper.getImageData().rotate, imageData.rotate);
+
+ cropper.scale(-1);
+ assert.strictEqual(cropper.getImageData().scaleX, imageData.scaleX);
+
+ canvasData = cropper.getCanvasData();
+ cropper.setCanvasData({
+ width: canvasData.width - 160
+ });
+ assert.deepEqual(cropper.getCanvasData(), canvasData);
+
+ cropBoxData = cropper.getCropBoxData();
+ cropper.setCropBoxData({
+ height: cropBoxData.height - 90
+ });
+ assert.deepEqual(cropper.getCropBoxData(), cropBoxData);
+
+ cropper.setAspectRatio(0.618);
+ assert.ok(isNaN(options.aspectRatio));
+
+ action = cropper.dragBox.dataset.action;
+ cropper.setDragMode('none');
+ assert.strictEqual(cropper.dragBox.dataset.action, action);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/enable.js b/library/cropperjs/test/methods/enable.js
new file mode 100644
index 000000000..ebd5b9529
--- /dev/null
+++ b/library/cropperjs/test/methods/enable.js
@@ -0,0 +1,23 @@
+QUnit.test('methods#enable', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+
+ cropper.disable();
+ assert.ok(cropper.disabled);
+ assert.ok(util.hasClass(cropper.cropper, 'cropper-disabled'));
+
+ cropper.enable();
+ assert.notOk(cropper.disabled);
+ assert.notOk(util.hasClass(cropper.cropper, 'cropper-disabled'));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/getCanvasData.js b/library/cropperjs/test/methods/getCanvasData.js
new file mode 100644
index 000000000..60d96af4e
--- /dev/null
+++ b/library/cropperjs/test/methods/getCanvasData.js
@@ -0,0 +1,23 @@
+QUnit.test('methods#getCanvasData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(6);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvasData = cropper.getCanvasData();
+
+ assert.ok(util.isNumber(canvasData.left));
+ assert.ok(util.isNumber(canvasData.top));
+ assert.ok(util.isNumber(canvasData.width));
+ assert.ok(util.isNumber(canvasData.height));
+ assert.ok(util.isNumber(canvasData.naturalWidth));
+ assert.ok(util.isNumber(canvasData.naturalHeight));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/getContainerData.js b/library/cropperjs/test/methods/getContainerData.js
new file mode 100644
index 000000000..094421ba0
--- /dev/null
+++ b/library/cropperjs/test/methods/getContainerData.js
@@ -0,0 +1,19 @@
+QUnit.test('methods#getContainerData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var containerData = cropper.getContainerData();
+
+ assert.ok(util.isNumber(containerData.width));
+ assert.ok(util.isNumber(containerData.height));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/getCropBoxData.js b/library/cropperjs/test/methods/getCropBoxData.js
new file mode 100644
index 000000000..844c7953e
--- /dev/null
+++ b/library/cropperjs/test/methods/getCropBoxData.js
@@ -0,0 +1,21 @@
+QUnit.test('methods#getCropBoxData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var cropBoxData = cropper.getCropBoxData();
+
+ assert.ok(util.isNumber(cropBoxData.left));
+ assert.ok(util.isNumber(cropBoxData.top));
+ assert.ok(util.isNumber(cropBoxData.width));
+ assert.ok(util.isNumber(cropBoxData.height));
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/getCroppedCanvas.js b/library/cropperjs/test/methods/getCroppedCanvas.js
new file mode 100644
index 000000000..4117497a5
--- /dev/null
+++ b/library/cropperjs/test/methods/getCroppedCanvas.js
@@ -0,0 +1,33 @@
+QUnit.test('methods#getCroppedCanvas', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(7);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvas = cropper.getCroppedCanvas({
+ width: 160,
+ height: 90
+ });
+ var pixelData;
+
+ assert.ok(canvas instanceof HTMLCanvasElement);
+ assert.strictEqual(canvas.width, 160);
+ assert.strictEqual(canvas.height, 90);
+
+ canvas = cropper.rotate(90).getCroppedCanvas({
+ fillColor: '#010101'
+ });
+ pixelData = canvas.getContext('2d').getImageData(0, 0, 1, 1).data;
+ assert.strictEqual(pixelData[0], 1, 'red is 1');
+ assert.strictEqual(pixelData[1], 1, 'green is 1');
+ assert.strictEqual(pixelData[2], 1, 'blue is 1');
+ assert.strictEqual(pixelData[3], 255, 'color is opaque');
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/getData.js b/library/cropperjs/test/methods/getData.js
new file mode 100644
index 000000000..9c519eb7f
--- /dev/null
+++ b/library/cropperjs/test/methods/getData.js
@@ -0,0 +1,46 @@
+QUnit.test('methods#getData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(7);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var data = cropper.getData();
+
+ assert.ok(util.isNumber(data.x));
+ assert.ok(util.isNumber(data.y));
+ assert.ok(util.isNumber(data.width));
+ assert.ok(util.isNumber(data.height));
+ assert.ok(util.isNumber(data.rotate));
+ assert.ok(util.isNumber(data.scaleX));
+ assert.ok(util.isNumber(data.scaleY));
+
+ done();
+ }
+ });
+});
+
+QUnit.test('methods#getData: rounded', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var data = cropper.getData(true);
+
+ assert.ok(data.x % 1 === 0);
+ assert.ok(data.y % 1 === 0);
+ assert.ok(data.width % 1 === 0);
+ assert.ok(data.height % 1 === 0);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/getImageData.js b/library/cropperjs/test/methods/getImageData.js
new file mode 100644
index 000000000..bd6e1941d
--- /dev/null
+++ b/library/cropperjs/test/methods/getImageData.js
@@ -0,0 +1,31 @@
+QUnit.test('methods#getImageData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(10);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var imageData = cropper.getImageData();
+
+ assert.ok(util.isNumber(imageData.naturalWidth));
+ assert.ok(util.isNumber(imageData.naturalHeight));
+ assert.ok(util.isNumber(imageData.aspectRatio));
+ assert.ok(util.isNumber(imageData.left));
+ assert.ok(util.isNumber(imageData.top));
+ assert.ok(util.isNumber(imageData.width));
+ assert.ok(util.isNumber(imageData.height));
+
+ imageData = cropper.rotateTo(45).getImageData();
+ assert.strictEqual(imageData.rotate, 45);
+
+ imageData = cropper.scale(-1, -1).getImageData();
+ assert.strictEqual(imageData.scaleX, -1);
+ assert.strictEqual(imageData.scaleY, -1);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/move.js b/library/cropperjs/test/methods/move.js
new file mode 100644
index 000000000..c2ead8412
--- /dev/null
+++ b/library/cropperjs/test/methods/move.js
@@ -0,0 +1,20 @@
+QUnit.test('methods#move', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvasData = cropper.getCanvasData();
+ var changedCanvasData = cropper.move(1, 1).getCanvasData();
+
+ assert.strictEqual(changedCanvasData.left, canvasData.left + 1);
+ assert.strictEqual(changedCanvasData.top, canvasData.top + 1);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/moveTo.js b/library/cropperjs/test/methods/moveTo.js
new file mode 100644
index 000000000..e8bf0eebd
--- /dev/null
+++ b/library/cropperjs/test/methods/moveTo.js
@@ -0,0 +1,19 @@
+QUnit.test('methods#moveTo', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvasData = cropper.moveTo(0, 0).getCanvasData();
+
+ assert.strictEqual(canvasData.left, 0);
+ assert.strictEqual(canvasData.top, 0);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/replace.js b/library/cropperjs/test/methods/replace.js
new file mode 100644
index 000000000..3fc8fe0b6
--- /dev/null
+++ b/library/cropperjs/test/methods/replace.js
@@ -0,0 +1,23 @@
+QUnit.test('methods#replace', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+
+ cropper.options.ready = function () {
+ assert.notOk(cropper.cropped);
+ cropper.crop();
+ assert.ok(cropper.cropped);
+ done();
+ };
+
+ cropper.options.autoCrop = false;
+ cropper.replace('../docs/images/picture-2.jpg');
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/reset.js b/library/cropperjs/test/methods/reset.js
new file mode 100644
index 000000000..3e047394c
--- /dev/null
+++ b/library/cropperjs/test/methods/reset.js
@@ -0,0 +1,35 @@
+QUnit.test('methods#reset', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvasData = cropper.getCanvasData();
+ var cropBoxData = cropper.getCropBoxData();
+
+ cropper.setCanvasData({
+ top: canvasData.top + 10,
+ width: canvasData.width - 10
+ });
+
+ assert.notDeepEqual(cropper.getCanvasData(), canvasData);
+
+ cropper.setCropBoxData({
+ left: cropBoxData.left + 10,
+ height: cropBoxData.height - 10
+ });
+
+ assert.notDeepEqual(cropper.getCropBoxData(), cropBoxData);
+
+ cropper.reset();
+ assert.deepEqual(cropper.getCanvasData(), canvasData);
+ assert.deepEqual(cropper.getCropBoxData(), cropBoxData);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/rotate.js b/library/cropperjs/test/methods/rotate.js
new file mode 100644
index 000000000..749096f0b
--- /dev/null
+++ b/library/cropperjs/test/methods/rotate.js
@@ -0,0 +1,19 @@
+QUnit.test('methods#rotate', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(3);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+
+ assert.strictEqual(cropper.rotate(360).getImageData().rotate, 0);
+ assert.strictEqual(cropper.rotate(90).getImageData().rotate, 90);
+ assert.strictEqual(cropper.rotate(-180).getImageData().rotate, -90);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/rotateTo.js b/library/cropperjs/test/methods/rotateTo.js
new file mode 100644
index 000000000..323431e76
--- /dev/null
+++ b/library/cropperjs/test/methods/rotateTo.js
@@ -0,0 +1,20 @@
+QUnit.test('methods#rotateTo', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+
+ assert.strictEqual(cropper.rotateTo(360).getImageData().rotate, 0);
+ assert.strictEqual(cropper.rotateTo(90).getImageData().rotate, 90);
+ assert.strictEqual(cropper.rotateTo(0).getImageData().rotate, 0);
+ assert.strictEqual(cropper.rotateTo(-180).getImageData().rotate, -180);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/scale.js b/library/cropperjs/test/methods/scale.js
new file mode 100644
index 000000000..be1caa589
--- /dev/null
+++ b/library/cropperjs/test/methods/scale.js
@@ -0,0 +1,19 @@
+QUnit.test('methods#scale', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var imageData = cropper.scale(-1, -1).getImageData();
+
+ assert.strictEqual(imageData.scaleX, -1);
+ assert.strictEqual(imageData.scaleY, -1);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/scaleX.js b/library/cropperjs/test/methods/scaleX.js
new file mode 100644
index 000000000..c799df58d
--- /dev/null
+++ b/library/cropperjs/test/methods/scaleX.js
@@ -0,0 +1,18 @@
+QUnit.test('methods#scaleX', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(1);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var imageData = cropper.scaleX(-1).getImageData();
+
+ assert.strictEqual(imageData.scaleX, -1);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/scaleY.js b/library/cropperjs/test/methods/scaleY.js
new file mode 100644
index 000000000..026b93a1f
--- /dev/null
+++ b/library/cropperjs/test/methods/scaleY.js
@@ -0,0 +1,18 @@
+QUnit.test('methods#scaleY', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(1);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var imageData = cropper.scaleY(-1).getImageData();
+
+ assert.strictEqual(imageData.scaleY, -1);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/setAspectRatio.js b/library/cropperjs/test/methods/setAspectRatio.js
new file mode 100644
index 000000000..ddf46798d
--- /dev/null
+++ b/library/cropperjs/test/methods/setAspectRatio.js
@@ -0,0 +1,20 @@
+QUnit.test('methods#setAspectRatio', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var options = cropper.options;
+
+ assert.ok(isNaN(options.aspectRatio));
+ cropper.setAspectRatio(1);
+ assert.strictEqual(options.aspectRatio, 1);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/setCanvasData.js b/library/cropperjs/test/methods/setCanvasData.js
new file mode 100644
index 000000000..e8f6511dc
--- /dev/null
+++ b/library/cropperjs/test/methods/setCanvasData.js
@@ -0,0 +1,34 @@
+QUnit.test('methods#setCanvasData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(6);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvasData = cropper.getCanvasData();
+ var changedCanvasData = cropper.setCanvasData({
+ left: 16,
+ top: 9
+ }).getCanvasData();
+
+ assert.notStrictEqual(changedCanvasData.left, canvasData.left);
+ assert.notStrictEqual(changedCanvasData.top, canvasData.top);
+ assert.strictEqual(changedCanvasData.width, canvasData.width);
+ assert.strictEqual(changedCanvasData.height, canvasData.height);
+
+ canvasData = cropper.getCanvasData();
+ changedCanvasData = cropper.setCanvasData({
+ width: 320,
+ height: 180
+ }).getCanvasData();
+
+ assert.notStrictEqual(changedCanvasData.width, canvasData.width);
+ assert.notStrictEqual(changedCanvasData.height, canvasData.height);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/setCropBoxData.js b/library/cropperjs/test/methods/setCropBoxData.js
new file mode 100644
index 000000000..e78767cfc
--- /dev/null
+++ b/library/cropperjs/test/methods/setCropBoxData.js
@@ -0,0 +1,36 @@
+QUnit.test('methods#setCropBoxData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(8);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var cropBoxData = cropper.getCropBoxData();
+ var changedCropBoxData = cropper.setCropBoxData({
+ left: 16,
+ top: 9
+ }).getCropBoxData();
+
+ assert.notStrictEqual(changedCropBoxData.left, cropBoxData.left);
+ assert.notStrictEqual(changedCropBoxData.top, cropBoxData.top);
+ assert.strictEqual(changedCropBoxData.width, cropBoxData.width);
+ assert.strictEqual(changedCropBoxData.height, cropBoxData.height);
+
+ cropBoxData = cropper.getCropBoxData();
+ changedCropBoxData = cropper.setCropBoxData({
+ width: 320,
+ height: 180
+ }).getCropBoxData();
+
+ assert.strictEqual(changedCropBoxData.left, cropBoxData.left);
+ assert.strictEqual(changedCropBoxData.top, cropBoxData.top);
+ assert.notStrictEqual(changedCropBoxData.width, cropBoxData.width);
+ assert.notStrictEqual(changedCropBoxData.height, cropBoxData.height);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/setData.js b/library/cropperjs/test/methods/setData.js
new file mode 100644
index 000000000..4e1360f09
--- /dev/null
+++ b/library/cropperjs/test/methods/setData.js
@@ -0,0 +1,36 @@
+QUnit.test('methods#setData', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(8);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var data = cropper.getData();
+ var changedData = cropper.setData({
+ x: 16,
+ y: 9
+ }).getData();
+
+ assert.notStrictEqual(changedData.x, data.x);
+ assert.notStrictEqual(changedData.y, data.y);
+ assert.strictEqual(changedData.width, data.width);
+ assert.strictEqual(changedData.height, data.height);
+
+ data = cropper.getData();
+ changedData = cropper.setData({
+ width: 320,
+ height: 180
+ }).getData();
+
+ assert.strictEqual(changedData.x, data.x);
+ assert.strictEqual(changedData.y, data.y);
+ assert.notStrictEqual(changedData.width, data.width);
+ assert.notStrictEqual(changedData.height, data.height);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/setDragMode.js b/library/cropperjs/test/methods/setDragMode.js
new file mode 100644
index 000000000..1b611af9b
--- /dev/null
+++ b/library/cropperjs/test/methods/setDragMode.js
@@ -0,0 +1,27 @@
+QUnit.test('methods#setDragMode', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(4);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var dragBox = cropper.dragBox;
+
+ assert.strictEqual(dragBox.dataset.action, 'crop');
+
+ cropper.setDragMode('move');
+ assert.strictEqual(dragBox.dataset.action, 'move');
+
+ cropper.setDragMode('crop');
+ assert.strictEqual(dragBox.dataset.action, 'crop');
+
+ cropper.setDragMode('none');
+ assert.strictEqual(dragBox.dataset.action, 'none');
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/zoom.js b/library/cropperjs/test/methods/zoom.js
new file mode 100644
index 000000000..70a1a763a
--- /dev/null
+++ b/library/cropperjs/test/methods/zoom.js
@@ -0,0 +1,20 @@
+QUnit.test('methods#zoom', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(2);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var canvasData = cropper.getCanvasData();
+ var changedCanvasData = cropper.zoom(0.1).getCanvasData();
+
+ assert.ok(changedCanvasData.width > canvasData.width);
+ assert.ok(changedCanvasData.height > canvasData.height);
+
+ done();
+ }
+ });
+});
diff --git a/library/cropperjs/test/methods/zoomTo.js b/library/cropperjs/test/methods/zoomTo.js
new file mode 100644
index 000000000..dd9e81760
--- /dev/null
+++ b/library/cropperjs/test/methods/zoomTo.js
@@ -0,0 +1,21 @@
+QUnit.test('methods#zoomTo', function (assert) {
+ var done = assert.async();
+ var util = window.Util;
+ var image = util.createImage();
+
+ assert.expect(3);
+
+ return new Cropper(image, {
+ ready: function () {
+ var cropper = this.cropper;
+ var imageData = cropper.zoomTo(1).getImageData();
+ var canvasData = cropper.getCanvasData();
+
+ assert.strictEqual(imageData.width, imageData.naturalWidth);
+ assert.strictEqual(canvasData.width, canvasData.naturalWidth);
+ assert.strictEqual(canvasData.naturalWidth, imageData.naturalWidth);
+
+ done();
+ }
+ });
+});