aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/options/zoomable.spec.js
blob: d0fbec5ec2c65181796bb17d034957a9318f795b (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
describe('zoomable (option)', () => {
  it('should be zoomable by default', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const canvasData = cropper.getCanvasData();
        const changedCanvasData = cropper.zoom(0.1).getCanvasData();

        expect(changedCanvasData.width).to.be.above(canvasData.width);
        expect(changedCanvasData.height).to.be.above(canvasData.height);
        done();
      },
    });

    expect(cropper.options.zoomable).to.be.true;
  });

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

      ready() {
        const canvasData = cropper.getCanvasData();
        const changedCanvasData = cropper.zoom(0.1).getCanvasData();

        expect(changedCanvasData.width).to.equal(canvasData.width);
        expect(changedCanvasData.height).to.equal(canvasData.height);
        done();
      },
    });

    expect(cropper.options.zoomable).to.be.false;
  });
});