45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
(function() {
|
|
|
|
QUnit.module('ImageEditor');
|
|
|
|
QUnit.test('load image', function(assert) {
|
|
var done = assert.async();
|
|
var editor = new ImageEditor('canvas');
|
|
editor.loadImage('fixtures/dog.jpg', function() {
|
|
assert.ok(editor.canvas.getImage(), 'image loaded');
|
|
done();
|
|
});
|
|
});
|
|
|
|
QUnit.test('crop image', function(assert) {
|
|
var done = assert.async();
|
|
var editor = new ImageEditor('canvas', {type: 'photo-wallpaper'});
|
|
editor.loadImage('fixtures/dog.jpg', function() {
|
|
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.strictEqual(data.y.toFixed(7), (0.12482117310443483).toFixed(7), 'sets crop y');
|
|
done();
|
|
});
|
|
});
|
|
|
|
QUnit.test('repeating wallpaper has x and y set to 0', function(assert) {
|
|
var done = assert.async();
|
|
var editor = new ImageEditor('canvas', {type: 'wallpaper'});
|
|
editor.loadImage('fixtures/dog.jpg', function() {
|
|
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.strictEqual(data.y, 0, 'sets crop y');
|
|
done();
|
|
});
|
|
});
|
|
|
|
})();
|