blob: c827067b7c906a5186c9142f9e6ddef566952542 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
describe('zoom (event)', () => {
it('should trigger the `zoom` event', (done) => {
const image = window.createImage();
let cropper;
image.addEventListener('ready', () => {
cropper.zoom(0.1);
});
image.addEventListener('zoom', (event) => {
expect(event.type).to.equal('zoom');
done();
});
cropper = new Cropper(image);
});
it('should have correct properties in `event.detail`', (done) => {
const image = window.createImage();
let cropper;
image.addEventListener('ready', () => {
cropper.zoom(0.1);
});
image.addEventListener('zoom', (event) => {
expect(event.detail).to.be.an('object').that.has.all.keys(['ratio', 'oldRatio', 'originalEvent']);
expect(event.detail.ratio).to.be.a('number');
expect(event.detail.oldRatio).to.be.a('number');
expect(event.detail.ratio).to.be.above(0);
expect(event.detail.oldRatio).to.be.above(0);
expect(event.detail.ratio).to.be.above(event.detail.oldRatio);
done();
});
cropper = new Cropper(image);
});
it('should not change the canvas sizes when default prevented', (done) => {
const image = window.createImage();
let cropper;
image.addEventListener('ready', () => {
const canvasData = cropper.getCanvasData();
expect(cropper.zoom(0.1).getCanvasData()).to.deep.equal(canvasData);
done();
});
image.addEventListener('zoom', (event) => {
event.preventDefault();
});
cropper = new Cropper(image);
});
});
|