use imageData in the crop test

This commit is contained in:
Martin
2017-08-05 13:17:14 +02:00
parent 6015c309cc
commit 31f06ad2ed
+6 -7
View File
@@ -13,13 +13,12 @@ QUnit.test('should crop image', function( assert ) {
var done = assert.async();
var editor = new ImageEditor('canvas');
editor.loadImage('fixtures/dog.jpg', function() {
editor.crop(400, 100, 'cm');
var data = editor.canvas.getViewport().getData();
assert.equal(data.dim.width, 400, 'sets crop width');
assert.equal(data.dim.height, 100, 'sets crop height');
assert.equal(data.dim.units, 'cm', 'set units');
assert.equal(data.width, 1049, 'sets image width');
assert.equal(data.height, 262.25, 'sets image height');
editor.crop(400, 200, 'cm');
var data = editor.canvas.getImageData().getData();
assert.strictEqual(data.width, 400, 'sets image width');
assert.strictEqual(data.height, 200, 'sets image height');
assert.strictEqual(data.x, 0, 'sets crop x');
assert.equal(data.y, 0.12482117310443483, 'sets crop y');
done();
});
});