aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/specs/methods/move.spec.js
blob: 8f89ba5e83a7b8083e78bdb529055a5ed2ce4f09 (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
describe('move (method)', () => {
  it('should move with the given offsets', (done) => {
    const image = window.createImage();
    const cropper = new Cropper(image, {
      ready() {
        const canvasData = cropper.getCanvasData();
        const changedCanvasData = cropper.move(1, 1).getCanvasData();

        expect(changedCanvasData.left).to.equal(canvasData.left + 1);
        expect(changedCanvasData.top).to.equal(canvasData.top + 1);
        done();
      },
    });
  });

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

      ready() {
        const canvasData = cropper.getCanvasData();
        const changedCanvasData = cropper.move(1, 1).getCanvasData();

        expect(changedCanvasData.left).to.equal(canvasData.left);
        expect(changedCanvasData.top).to.equal(canvasData.top);
        done();
      },
    });
  });
});