aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/methods/zoomTo.spec.js
blob: a06730485c9241dc2b6543c34ea5a4c1bcb09344 (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
describe('zoomTo (method)', () => {
  it('should zoom to the certain ratio', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const imageData = cropper.zoomTo(1).getImageData();
        const canvasData = cropper.getCanvasData();

        expect(imageData.width).to.equal(imageData.naturalWidth);
        expect(canvasData.width).to.equal(canvasData.naturalWidth);
        expect(canvasData.naturalWidth).to.equal(imageData.naturalWidth);
        done();
      },
    });
  });

  it('should not be zoomed when it is not zoomable', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      zoomable: false,

      ready() {
        const imageData = cropper.zoomTo(1).getImageData();
        const canvasData = cropper.getCanvasData();

        expect(imageData.width).to.not.equal(imageData.naturalWidth);
        expect(canvasData.width).to.not.equal(canvasData.naturalWidth);
        expect(canvasData.naturalWidth).to.equal(imageData.naturalWidth);
        done();
      },
    });
  });
});